<html>
<head><meta charset="utf-8"><title>noexcept-like feature · project-ffi-unwind · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/index.html">project-ffi-unwind</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html">noexcept-like feature</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="178839028"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/178839028" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#178839028">(Oct 23 2019 at 10:00)</a>:</h4>
<p>The points I tried to make is that a <code>#[no_unwind]</code> attribute that you can stamp on a function is a large language change</p>



<a name="178839050"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/178839050" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#178839050">(Oct 23 2019 at 10:01)</a>:</h4>
<p>which impacts many parts of the language and the library long term</p>



<a name="178839070"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/178839070" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#178839070">(Oct 23 2019 at 10:01)</a>:</h4>
<p>an <code>extern "C nounwind"</code> ABI feels much restricted in scope</p>



<a name="178839161"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/178839161" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#178839161">(Oct 23 2019 at 10:02)</a>:</h4>
<p>it still allows many things that a <code>noexcept</code>-like feature would allow though</p>



<a name="178839302"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/178839302" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#178839302">(Oct 23 2019 at 10:04)</a>:</h4>
<p>e.g. you can implement traits for function types with that ABI, which lets you query whether a function call might panic in an adhoc way:</p>
<div class="codehilite"><pre><span></span><span class="k">trait</span><span class="w"> </span><span class="n">CanUnwind</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="n">VALUE</span>: <span class="kt">bool</span> <span class="p">}</span><span class="w"></span>
<span class="k">impl</span><span class="o">&lt;</span><span class="n">Args</span><span class="p">...,</span><span class="w"> </span><span class="n">Ret</span><span class="o">&gt;</span><span class="w"> </span><span class="n">CanUnwind</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="k">extern</span><span class="w"> </span><span class="s">&quot;C nounwind&quot;</span><span class="w"> </span><span class="k">fn</span><span class="p">(</span><span class="n">Args</span><span class="p">...)</span><span class="w"> </span>-&gt; <span class="nc">Ret</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="n">VALUE</span>: <span class="kt">bool</span> <span class="o">=</span><span class="w"> </span><span class="kc">false</span><span class="p">;</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="k">impl</span><span class="o">&lt;</span><span class="n">Args</span><span class="p">...,</span><span class="w"> </span><span class="n">Ret</span><span class="o">&gt;</span><span class="w"> </span><span class="n">CanUnwind</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="k">extern</span><span class="w"> </span><span class="s">&quot;C&quot;</span><span class="w"> </span><span class="k">fn</span><span class="p">(</span><span class="n">Args</span><span class="p">...)</span>-&gt; <span class="nc">Ret</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="n">VALUE</span>: <span class="kt">bool</span> <span class="o">=</span><span class="w"> </span><span class="kc">true</span><span class="p">;</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
</pre></div>



<a name="178839340"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/178839340" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#178839340">(Oct 23 2019 at 10:05)</a>:</h4>
<p>(or using specialization you can do better)</p>



<a name="178839369"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/178839369" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#178839369">(Oct 23 2019 at 10:05)</a>:</h4>
<p>A <code>"C unwind"</code> feature also allows this, I don't think we mentioned that anywhere</p>



<a name="178839560"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/178839560" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#178839560">(Oct 23 2019 at 10:08)</a>:</h4>
<p>An "ABI" string restricts the ABIs that can use such a <code>noexcept</code>-like feature, but that's essentially it.</p>



<a name="178839744"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/178839744" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#178839744">(Oct 23 2019 at 10:11)</a>:</h4>
<p>It would be unfortunate to end up with both a <code>noexcept</code>-like feature and ABIs of the form <code>"X"</code> and <code>"X nounwind/unwind"</code> requiring user code to handle both</p>



<a name="178840144"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/178840144" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#178840144">(Oct 23 2019 at 10:18)</a>:</h4>
<p>I would argue that we do not need the full functionality of <code>noexcept</code> in Rust. In C++, some functions need to work differently if a move constructor might throw an exception since you could end up in a situation with a partially moved value that you can't fully move back without triggering a second exception. The <code>noexcept</code> detection is used to fall back to copy constructors (i.e. <code>Clone</code> in Rust) in such cases. This is the <em>only</em> legitimate use of <code>noexcept</code> detection in C++ that I know of, and it doesn't apply to Rust because moving an object is just a memcpy and is guaranteed not to panic.</p>



<a name="178840536"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/178840536" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#178840536">(Oct 23 2019 at 10:24)</a>:</h4>
<p>However in Rust I can see a use for <code>#[no_unwind]</code> for utilities such as <a href="https://github.com/Sgeo/take_mut" target="_blank" title="https://github.com/Sgeo/take_mut"><code>take_mut</code></a> where unwinding would leave things in an unsound state.</p>



<a name="178855479"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/178855479" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#178855479">(Oct 23 2019 at 13:53)</a>:</h4>
<p><span class="user-mention" data-user-id="143274">@Amanieu</span> another legitimate use of <code>noexcept</code> in C++ is some algorithmic optimizations</p>



<a name="178855588"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/178855588" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#178855588">(Oct 23 2019 at 13:54)</a>:</h4>
<p>maybe that's what you meant above, but if you know that, e.g., a move constructor cannot panic, then you can just avoid doing certain work</p>



<a name="178855611"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/178855611" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#178855611">(Oct 23 2019 at 13:55)</a>:</h4>
<p>In Rust, <code>catch_unwind(never_panics)</code> is not free (on the contrary, it is super expensive)</p>



<a name="178855743"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/178855743" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#178855743">(Oct 23 2019 at 13:56)</a>:</h4>
<p>so an implementation of <code>catch_unwind</code> that is able to use something like <code>noexcept(never_panics())</code> could be much better, but for that, such a <code>noexcept</code> feature is not really required</p>



<a name="178855777"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/178855777" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#178855777">(Oct 23 2019 at 13:56)</a>:</h4>
<p>(we could have something like <code>needs_drop</code>, that doesn't need to return a reliable answer, and that could be able to do more than just looking at the functions type)</p>



<a name="178855916"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/178855916" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#178855916">(Oct 23 2019 at 13:58)</a>:</h4>
<p><span class="user-mention" data-user-id="143274">@Amanieu</span> </p>
<blockquote>
<p>However in Rust I can see a use for #[no_unwind] for utilities such as take_mut where unwinding would leave things in an unsound state.</p>
</blockquote>
<p>Isn't that the problem that <code>UnwindSafe</code> solved ? (I'm not sure I understood that part of Rust though)</p>



<a name="178856143"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/178856143" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#178856143">(Oct 23 2019 at 14:00)</a>:</h4>
<p>Another legitimate use of <code>noexcept</code> is to just say "this operation never panics and that's part of its API". That's important when violating unsafe invariants.</p>



<a name="178856182"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/178856182" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#178856182">(Oct 23 2019 at 14:00)</a>:</h4>
<p>e.g. </p>
<div class="codehilite"><pre><span></span><span class="n">vec</span><span class="p">.</span><span class="n">set_len</span><span class="p">(</span><span class="n">x</span><span class="p">);</span><span class="w"> </span><span class="c1">// vec invariants violated</span>
<span class="c1">// do stuff</span>
<span class="n">ptr</span>::<span class="n">write</span><span class="p">(...</span><span class="n">to</span><span class="w"> </span><span class="n">the</span><span class="w"> </span><span class="n">vec</span><span class="p">...);</span><span class="w">  </span><span class="c1">// vec invariants restored</span>
</pre></div>



<a name="178856261"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/178856261" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#178856261">(Oct 23 2019 at 14:01)</a>:</h4>
<p>you can defend against "do stuff" panicking, e.g., by having some <code>DropGuard</code> on the stack that restores the <code>vec</code> invariants before letting "do stuff" panic escape</p>



<a name="178856422"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/178856422" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#178856422">(Oct 23 2019 at 14:03)</a>:</h4>
<p>but you don't have to do that if "do stuff" does not panic, and you might prefer to simplify your code by not allowing "do stuff" to panic at all</p>



<a name="178856596"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/178856596" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#178856596">(Oct 23 2019 at 14:04)</a>:</h4>
<p>with something like <code>needs_drop</code> but for panic, e.g., <code>might_panic</code>, you can just test if a user-provided <code>Fn</code> type might panic, and just abort, but you might want to lift that to a type-error, to let the user know that <code>Fn</code> types that can panic cannot be provided to that particular operation</p>



<a name="178857159"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/178857159" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#178857159">(Oct 23 2019 at 14:11)</a>:</h4>
<p>So I think there are two major use cases:</p>
<ul>
<li>optimizations if some operation cannot unwind: a <code>might_panic</code>-kind of intrinsic might allow these</li>
<li>API contracts: Some unsafe code is only sound if certain expressions do not unwind and it might make sense to turn these into type errors in some cases, and certain APIs want to guarantee that they never unwind as part of their API contract (not only in a doc comment, but also in code).</li>
</ul>



<a name="178859802"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/178859802" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#178859802">(Oct 23 2019 at 14:38)</a>:</h4>
<p><span class="user-mention" data-user-id="132920">@gnzlbg</span> My point is, <code>noexcept</code> optimizations in C++ are almost exclusively based on move constructors, and Rust doesn't have that problem since move can never panic in Rust.</p>



<a name="178860037"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/178860037" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#178860037">(Oct 23 2019 at 14:40)</a>:</h4>
<p>Is that true?</p>



<a name="178860057"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/178860057" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#178860057">(Oct 23 2019 at 14:41)</a>:</h4>
<p>I see <code>noexcept</code> being used for optimizations that require exception safety</p>



<a name="178860126"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/178860126" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#178860126">(Oct 23 2019 at 14:41)</a>:</h4>
<p>For example, consider <code>sort</code> in the standard library, which uses <code>merge_sort</code></p>



<a name="178860162"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/178860162" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#178860162">(Oct 23 2019 at 14:42)</a>:</h4>
<p>The input slice is always kept in a valid state because the user comparison operations can panic</p>



<a name="178860227"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/178860227" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#178860227">(Oct 23 2019 at 14:42)</a>:</h4>
<p>That is, the elements of the input slice are only swapped to avoid leaving holes on panic</p>



<a name="178860324"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/178860324" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#178860324">(Oct 23 2019 at 14:43)</a>:</h4>
<p>If we would be able to tell that the user-provided operation does not panic, we could maybe do a bit better there</p>



<a name="178860349"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/178860349" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#178860349">(Oct 23 2019 at 14:43)</a>:</h4>
<p>e.g. leaving "holes" in the slice while operating on it</p>



<a name="178860426"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/178860426" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#178860426">(Oct 23 2019 at 14:44)</a>:</h4>
<p>we often deal with such things by using "<code>DropGuard</code>"s, that on panic, restore all broken invariants</p>



<a name="178860492"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/178860492" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#178860492">(Oct 23 2019 at 14:44)</a>:</h4>
<p>but those <code>DropGuard</code>s are tricky to write correctly, and we have had a couple of issues with them, e.g., in the <code>Iterator</code>s of the collections..</p>



<a name="178860644"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/178860644" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#178860644">(Oct 23 2019 at 14:46)</a>:</h4>
<p>All use cases of <code>DropGuard</code>s in <code>libstd</code> that I know about are optimizations that violate safety invariants that, in case of a panic, need to be restored</p>



<a name="178865541"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/178865541" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#178865541">(Oct 23 2019 at 15:31)</a>:</h4>
<p>But <code>DropGuard</code> are the best way to solve this problem. They are optimized away when the compiler inlines the user callback and can see that it doesn't panic.</p>



<a name="178865600"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/178865600" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#178865600">(Oct 23 2019 at 15:31)</a>:</h4>
<p>We are able to restore the structure to a safe state with <code>DropGuard</code> <em>because</em> Rust doesn't have move constructors.</p>



<a name="178865696"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/178865696" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#178865696">(Oct 23 2019 at 15:32)</a>:</h4>
<p>In C++ you would need to take into account the possibility that even moving objects around can throw exceptions.</p>



<a name="178877204"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/178877204" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#178877204">(Oct 23 2019 at 17:37)</a>:</h4>
<blockquote>
<p>But <code>DropGuard</code> are the best way to solve this problem. They are optimized away when the compiler inlines the user callback and can see that it doesn't panic.</p>
</blockquote>
<p>If the compiler inlines the callback. With <code>noexcept</code> you don't need inlining for this to happen.</p>



<a name="178880573"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/178880573" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#178880573">(Oct 23 2019 at 18:11)</a>:</h4>
<p>It seems the fundamental consideration here is that <code>no_except</code> is <em>strictly</em> an optimization, is <em>never</em> required for correctness, and, regardless of the final design, can be added in a fully backwards-compatible way</p>



<a name="178880684"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/178880684" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#178880684">(Oct 23 2019 at 18:12)</a>:</h4>
<p>So my current view is: it does (probably) fall within the scope of the WG, but does not need to be resolved in order to stabilize cross-FFI-unwinding</p>



<a name="178880761"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/178880761" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#178880761">(Oct 23 2019 at 18:13)</a>:</h4>
<p>Does the first sentence seem accurate and the second reasonable?</p>



<a name="178880801"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/178880801" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#178880801">(Oct 23 2019 at 18:13)</a>:</h4>
<p>If so, I'm happy for continued discussion to take place here, but I would like it to be "officially" considered a low priority for now</p>



<a name="178880852"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/178880852" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#178880852">(Oct 23 2019 at 18:14)</a>:</h4>
<p>(But definitely something that our first technical RFC should mention in the "future possibilities" section)</p>



<a name="178901298"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/178901298" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#178901298">(Oct 23 2019 at 22:04)</a>:</h4>
<p>I think <code>nopanic fn</code> or some such should be viewed in the same light as <code>const fn</code> -- it is a restriction to the base effect <code>fn</code> has which may 1) diverge, 2) panic, and 3) cause side-effects.</p>
<blockquote>
<p>So I think there are two major use cases:</p>
</blockquote>
<p>I think there's interest in embedded to prevent panics.<br>
Fundamentally, restrictions like <code>const</code> (interpreted as "pure") and "cannot panic" also improve code quality beyond usefulness for soundness.<br>
It's a way to be sure that you've handled more cases, enhancing strong typing. I think this is desirable, but way out of scope for this WG.</p>



<a name="178901328"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/178901328" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#178901328">(Oct 23 2019 at 22:04)</a>:</h4>
<p>(I also think provable convergence (e.g. <code>total fn</code>) is desirable, but that's more difficult to make ergonomic)</p>



<a name="178901437"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/178901437" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#178901437">(Oct 23 2019 at 22:06)</a>:</h4>
<p>Note that what we proposed for a <code>nopanic</code> attribute is not what you described. Instead, if unwinding reaches a <code>nopanic</code>, it aborts the process instead of continuing to unwind.</p>



<a name="178901757"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/178901757" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#178901757">(Oct 23 2019 at 22:12)</a>:</h4>
<p>Seems strange to me, especially when combined with a closure</p>



<a name="178901854"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/178901854" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#178901854">(Oct 23 2019 at 22:13)</a>:</h4>
<div class="codehilite"><pre><span></span><span class="k">pub</span><span class="w"> </span><span class="k">fn</span> <span class="nf">take</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">(</span><span class="n">mut_ref</span>: <span class="kp">&amp;</span><span class="nc">mut</span><span class="w"> </span><span class="n">T</span><span class="p">,</span><span class="w"> </span><span class="n">closure</span>: <span class="nc">impl</span><span class="w"> </span><span class="n">nopanic</span><span class="w"> </span><span class="nb">FnOnce</span><span class="p">(</span><span class="n">T</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">T</span><span class="p">);</span><span class="w"></span>
<span class="c1">//~^ You cannot pass a closure that will panic; the type system will prevent it</span>
</pre></div>



<a name="178902042"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/178902042" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#178902042">(Oct 23 2019 at 22:16)</a>:</h4>
<p>The attribute being discussed here is for optimization, not an effects system. The effects system "can't panic" type does sound interesting, but isn't what <code>#[no_unwind]</code> would be.</p>



<a name="178902435"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/178902435" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#178902435">(Oct 23 2019 at 22:21)</a>:</h4>
<p>When <code>take_mut</code> is being discussed that is for soundness; not optimization.</p>
<p>This <code>#[no_unwind]</code>... is it attached just to function definitions? function pointers? closures? what exactly?</p>



<a name="178903123"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/178903123" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#178903123">(Oct 23 2019 at 22:32)</a>:</h4>
<p>I think there's a bit of confusion here because there are actually two similar but different attributes being discussed here:<br>
- First, an attribute that you can place on (FFI) declarations which (unsafely) tells the compiler that this function will never unwind. This is basically the LLVM <code>nounwind</code> attribute.<br>
- Second, an attribute on a function definition which forces unwinding to abort the process if it reaches this function. Incidentally, this function can also be marked with LLVM's <code>nounwind</code> since no exceptions will ever unwind out of it (they'll abort first).</p>



<a name="178903189"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/178903189" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#178903189">(Oct 23 2019 at 22:33)</a>:</h4>
<p>This seems to be <code>#[unwind(aborts)]</code>?</p>



<a name="178906723"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/178906723" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#178906723">(Oct 23 2019 at 23:26)</a>:</h4>
<p>Yes, I believe that's the main thing being discussed that we believe would be in scope for this project</p>



<a name="178926841"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/178926841" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#178926841">(Oct 24 2019 at 07:17)</a>:</h4>
<blockquote>
<p>It seems the fundamental consideration here is that no_except is strictly an optimization, is never required for correctness, </p>
</blockquote>
<p><span class="user-mention" data-user-id="120076">@Kyle Strand</span>  How do you arrive at this conclusion? The example I showed is only correct if some code cannot ever unwind, i.e., without <code>noexcept</code>, such unsafe code is unsound.</p>



<a name="178926909"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/178926909" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#178926909">(Oct 24 2019 at 07:18)</a>:</h4>
<p>That's not an optimization, but a requirement for correctness.</p>



<a name="178927215"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/178927215" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#178927215">(Oct 24 2019 at 07:25)</a>:</h4>
<p><span class="user-mention" data-user-id="126931">@centril</span> </p>
<blockquote>
<p>I think there's interest in embedded to prevent panics.</p>
</blockquote>
<p>There are many users of dtolnay's <code>#[no_panic]</code> crate, which has a proc-macro that wraps a function, in such a way that it only compiles if it cannot panic. It does so by wrapping the function in another function, that contains a type in the stack with a destructor that's only called if the original function can panic. That destructor is implemented to call an external symbol that does not exist. So if the destructor call is optimized away because the function is proven not to panic, then your program compiles. Otherwise, your program fails to link.</p>
<p>The existence of users that are willing to go to such hacky extends to make sure that a function cannot panic shows that there is more than interest, there is an active need.</p>



<a name="178927395"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/178927395" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#178927395">(Oct 24 2019 at 07:29)</a>:</h4>
<blockquote>
<p>The attribute being discussed here is for optimization, not an effects system. </p>
</blockquote>
<p><span class="user-mention" data-user-id="120076">@Kyle Strand</span>  This is unclear to me, since <span class="user-mention" data-user-id="143274">@Amanieu</span> also claimed that they would be good with a <code>"C nounwind"</code> ABI string that makes this part of the type system.</p>



<a name="178927465"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/178927465" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#178927465">(Oct 24 2019 at 07:30)</a>:</h4>
<p>If the only goal is optimizations, then making it part of the type system would be a bad idea.</p>



<a name="178927489"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/178927489" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#178927489">(Oct 24 2019 at 07:31)</a>:</h4>
<p>If it makes sense to make this part of the type system, then designing the feature only for optimizations and neglecting how it impacts the type system as a whole is probably a bad idea as well.</p>



<a name="179272812"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179272812" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179272812">(Oct 28 2019 at 20:34)</a>:</h4>
<blockquote>
<blockquote>
<p>It seems the fundamental consideration here is that no_except is strictly an optimization, is never required for correctness, </p>
</blockquote>
<p><span class="user-mention silent" data-user-id="120076">Kyle Strand</span>  How do you arrive at this conclusion? The example I showed is only correct if some code cannot ever unwind, i.e., without <code>noexcept</code>, such unsafe code is unsound.</p>
</blockquote>
<p>Looking back, I have to admit I'm not entirely sure what I meant by that. But if ensuring a function can't <code>panic</code> is required for correctness, you can just put a <code>catch_panic</code> at the top with an <code>abort</code> statement. So I think what I was trying to say is that there is no case in which users would be unable to write some particular functionality _without_ <code>noexcept</code> that would be enabled by <code>noexcept</code>. Is that true?</p>



<a name="179306773"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179306773" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179306773">(Oct 29 2019 at 07:46)</a>:</h4>
<p>No.</p>



<a name="179306836"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179306836" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179306836">(Oct 29 2019 at 07:48)</a>:</h4>
<p>If <code>catch_unwind</code> were a zero-cost abstraction, then maybe. But a <code>catch_unwind</code> is extremely expensive, and if you are targeting a constrained environment, you can't use it.</p>



<a name="179306866"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179306866" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179306866">(Oct 29 2019 at 07:48)</a>:</h4>
<p><code>noexcept</code> removes the need for the <code>catch_unwind</code>, enabling that</p>



<a name="179333097"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179333097" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179333097">(Oct 29 2019 at 14:22)</a>:</h4>
<p>Hm. How would it remove that need? I am imagining here that <code>noexcept</code> would have the abort-on-unwind behavior that we want for <code>extern "C"</code>. Why is <code>catch_unwind</code> more expensive than that would be?</p>



<a name="179343628"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179343628" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179343628">(Oct 29 2019 at 15:59)</a>:</h4>
<p><code>noexcept</code> makes it a compiler error instead, removing any run-time cost</p>



<a name="179343730"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179343730" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179343730">(Oct 29 2019 at 16:00)</a>:</h4>
<p><code>catch_unwind</code> is probably just implemented "poorly"</p>



<a name="179343823"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179343823" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179343823">(Oct 29 2019 at 16:01)</a>:</h4>
<p>it's a library feature, not a language construct, and whatever LLVM-IR we generate doesn't get optimized, probably because of calls to unknown functions</p>



<a name="179344465"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179344465" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179344465">(Oct 29 2019 at 16:07)</a>:</h4>
<p>We discussed two variants of <code>noexcept</code>. If it's an effect annotation, that's out of scope. If it's like C++'s feature (which <code>std::terminate</code>s when an exception is thrown), that's probably in scope.</p>



<a name="179344639"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179344639" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179344639">(Oct 29 2019 at 16:08)</a>:</h4>
<p>Did you understood the code example that was shown above ?</p>



<a name="179344751"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179344751" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179344751">(Oct 29 2019 at 16:09)</a>:</h4>
<p>Centril's?</p>



<a name="179344777"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179344777" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179344777">(Oct 29 2019 at 16:09)</a>:</h4>
<p>All of them</p>



<a name="179346104"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179346104" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179346104">(Oct 29 2019 at 16:22)</a>:</h4>
<p>(there are 3 examples I think)</p>



<a name="179346113"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179346113" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179346113">(Oct 29 2019 at 16:22)</a>:</h4>
<p>The second one shows the issue</p>



<a name="179347284"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179347284" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179347284">(Oct 29 2019 at 16:35)</a>:</h4>
<p>The one about temporarily violating invariants e.g. w/ <code>vec.set_len</code>?</p>



<a name="179354078"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179354078" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179354078">(Oct 29 2019 at 17:42)</a>:</h4>
<p>Yep, <code>noexcept</code> makes such examples sound</p>



<a name="179355304"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179355304" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179355304">(Oct 29 2019 at 17:53)</a>:</h4>
<p>As does <code>catch_unwind</code> + <code>abort</code>. If there's an implementation reason why <code>catch_unwind</code> can't be used somewhere that <code>noexcept</code> (the version that causes an <code>abort</code>) would be usable, that seems separate from the consideration of whether <code>noexcept</code> is "required for correctness".</p>



<a name="179356361"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179356361" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179356361">(Oct 29 2019 at 18:02)</a>:</h4>
<p>_Again_, what you are proposing is for the error to be reported at run-time by aborting.</p>



<a name="179356369"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179356369" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179356369">(Oct 29 2019 at 18:03)</a>:</h4>
<p>If you want to ignore that, that's ok.</p>



<a name="179356393"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179356393" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179356393">(Oct 29 2019 at 18:03)</a>:</h4>
<p>I prefer code like <code>let x: u32 = 0_f32;</code> to error at compile-time due to a type error</p>



<a name="179356407"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179356407" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179356407">(Oct 29 2019 at 18:03)</a>:</h4>
<p>Sure, we could also make <code>let x: u32 = 0_f32;</code> "sound" by aborting the program at run-time</p>



<a name="179356555"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179356555" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179356555">(Oct 29 2019 at 18:04)</a>:</h4>
<p>but if I wanted a language that does that I would be using Python, and not Rust</p>



<a name="179356636"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179356636" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179356636">(Oct 29 2019 at 18:05)</a>:</h4>
<p>I'm not disagreeing that a compile-time error is <em>preferable</em> or even necessarily "proposing" something as such. I'm just saying that there are <em>two</em> "noexcept-like" features discussed above, and I don't believe that the "effects system" one is within the scope of this project group.</p>



<a name="179356908"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179356908" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179356908">(Oct 29 2019 at 18:07)</a>:</h4>
<p>I thought you were asking "what problems does <code>noexcept</code> solve", which is something that has been discussed above</p>



<a name="179356948"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179356948" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179356948">(Oct 29 2019 at 18:07)</a>:</h4>
<p>I am also trying to respond to your comment about unsoundness. The "effects system" version is a way to strengthen the type system to remove some of the soundness proof-burden from the user. The "abort on unwind" version is a way to ensure soundness at runtime via a mechanism that users could in theory implement themselves. Neither is "required" for soundness, though.</p>



<a name="179357053"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179357053" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179357053">(Oct 29 2019 at 18:08)</a>:</h4>
<p>You are forgetting the guarantee that <code>noexcept</code> provides <strong>for callers</strong></p>



<a name="179357071"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179357071" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179357071">(Oct 29 2019 at 18:08)</a>:</h4>
<p>which is that something won't unwind, ever</p>



<a name="179357113"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179357113" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179357113">(Oct 29 2019 at 18:09)</a>:</h4>
<p>this means, they don't even need to add a test to verify the behavior of the program if that something were to unwind, because it is something that, if the program compiles, is guaranteed not to happen</p>



<a name="179357137"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179357137" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179357137">(Oct 29 2019 at 18:09)</a>:</h4>
<p>and that's the property of <code>noexcept</code> that the example above requires</p>



<a name="179357269"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179357269" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179357269">(Oct 29 2019 at 18:10)</a>:</h4>
<p>Without a built-in effects system, callers are responsible for knowing whether function effects can cause unsoundness. That's why an effects system would be nice, but that doesn't mean it's in scope for this project group.</p>



<a name="179357299"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179357299" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179357299">(Oct 29 2019 at 18:10)</a>:</h4>
<p>C++ doesn't have an effect system, but it has this feature</p>



<a name="179357314"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179357314" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179357314">(Oct 29 2019 at 18:10)</a>:</h4>
<p>adding <del><code>"C unwind"</code></del> <code>"C nounwind"</code> is equivalent to adding <code>noexcept</code></p>



<a name="179357316"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179357316" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179357316">(Oct 29 2019 at 18:10)</a>:</h4>
<p>not...really....</p>



<a name="179357340"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179357340" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179357340">(Oct 29 2019 at 18:10)</a>:</h4>
<p>Do you mean <code>"C nounwind"</code>?</p>



<a name="179357351"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179357351" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179357351">(Oct 29 2019 at 18:10)</a>:</h4>
<blockquote>
<p>Do you mean "C nounwind"?</p>
</blockquote>
<p>Yes, or equivalently adding <code>"C unwind"</code> and making <code>"C"</code> <code>nounwind</code></p>



<a name="179357425"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179357425" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179357425">(Oct 29 2019 at 18:11)</a>:</h4>
<p>Okay. Again, I'm not trying to debate the merits of having <code>nounwind</code> in the type system, or anything like that.</p>



<a name="179357514"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179357514" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179357514">(Oct 29 2019 at 18:12)</a>:</h4>
<p>I agree that <code>"C nounwind"</code> and/or guaranteeing the <code>abort</code> behavior of <code>"C"</code> would both provide useful guarantees that aren't available in the type system today.</p>



<a name="179357525"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179357525" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179357525">(Oct 29 2019 at 18:12)</a>:</h4>
<p>Adding <code>"C unwind"</code> makes <code>"C" nounwind</code> and adds <code>noexcept</code> to Rust in some way</p>



<a name="179357539"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179357539" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179357539">(Oct 29 2019 at 18:12)</a>:</h4>
<p>Right</p>



<a name="179357561"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179357561" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179357561">(Oct 29 2019 at 18:13)</a>:</h4>
<p>Doing that, and then also adding another <code>noexcept</code> feature, would be adding two subtly different features to do the same thing to the language</p>



<a name="179357592"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179357592" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179357592">(Oct 29 2019 at 18:13)</a>:</h4>
<p>Yes, but they're semantically different in important ways, and I don't think it would be inappropriate to do so.</p>



<a name="179357601"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179357601" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179357601">(Oct 29 2019 at 18:13)</a>:</h4>
<p>So it is in scope for this working group to say why two different features instead of just one.</p>



<a name="179357659"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179357659" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179357659">(Oct 29 2019 at 18:13)</a>:</h4>
<p>They are identical</p>



<a name="179357691"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179357691" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179357691">(Oct 29 2019 at 18:14)</a>:</h4>
<p><code>"C unwind" nounwind</code> == <code>"C"</code></p>



<a name="179357698"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179357698" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179357698">(Oct 29 2019 at 18:14)</a>:</h4>
<p>Um....not really. Because the extra <code>noexcept</code> feature wouldn't fall within the scope of this group, so the burden to explain why it's non-redundant would be on whoever proposes it.</p>



<a name="179357782"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179357782" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179357782">(Oct 29 2019 at 18:14)</a>:</h4>
<p>Oh, wait, you're saying that <code>"C"</code> and <code>"C nounwind"</code> would be subtly different?</p>



<a name="179357820"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179357820" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179357820">(Oct 29 2019 at 18:15)</a>:</h4>
<blockquote>
<p>Um....not really. Because the extra noexcept feature wouldn't fall within the scope of this group, so the burden to explain why it's non-redundant would be on whoever proposes it.</p>
</blockquote>
<p>I strongly disagree. This process would result in thousand of small incoherent features being added to the language.</p>



<a name="179357833"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179357833" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179357833">(Oct 29 2019 at 18:15)</a>:</h4>
<p>I don't agree with that. <code>"C nounwind"</code> would just be an explicit way of writing <code>"C"</code>, just like <code>extern "Rust"</code> is merely an explicit way of specifying the default ABI.</p>



<a name="179357845"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179357845" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179357845">(Oct 29 2019 at 18:15)</a>:</h4>
<p>Because it would always be somebodyelses job to see the big picture.</p>



<a name="179357897"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179357897" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179357897">(Oct 29 2019 at 18:15)</a>:</h4>
<blockquote>
<p>Oh, wait, you're saying that "C" and "C nounwind" would be subtly different?</p>
</blockquote>
<p>No, I precisely meant what I said.</p>



<a name="179357988"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179357988" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179357988">(Oct 29 2019 at 18:16)</a>:</h4>
<p>I'm not accusing you of misspeaking; I'm trying to understand this comment:</p>
<blockquote>
<p><code>"C unwind" nounwind</code> == <code>"C"</code></p>
</blockquote>



<a name="179358040"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179358040" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179358040">(Oct 29 2019 at 18:16)</a>:</h4>
<p><code>nounwind extern "C unwind" fn foo() {}</code> would be semantically identical to <code>extern "C" fn foo() {}</code></p>



<a name="179358100"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179358100" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179358100">(Oct 29 2019 at 18:17)</a>:</h4>
<p>therefore by adding the <code>"C"</code> and <code>"C unwind"</code> ABIs distinction to the language one is actually adding <code>nounwind</code> to the language</p>



<a name="179358187"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179358187" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179358187">(Oct 29 2019 at 18:17)</a>:</h4>
<p>just with less explicit syntax, less powerful, and probably in such a way that actually making it more powerful would require a different feature that would subsume it and deprecate it</p>



<a name="179358256"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179358256" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179358256">(Oct 29 2019 at 18:18)</a>:</h4>
<p>that's the opposite of "future proofing" a feature</p>



<a name="179358308"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179358308" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179358308">(Oct 29 2019 at 18:19)</a>:</h4>
<p>When you write <code>nounwind</code> outside of an <code>extern</code> ABI specifier, is that your hypothetical syntax for what I'm calling an "effects system" <code>nounwind</code>, i.e., purely a compile-time guarantee, with no runtime <code>abort</code>?</p>



<a name="179360333"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179360333" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179360333">(Oct 29 2019 at 18:36)</a>:</h4>
<p>If so, I agree that those are semantically identical from the perspective of the <em>caller</em>, though specifying both <code>"C unwind"</code> and <code>nounwind</code> seems...confused at best.</p>



<a name="179360365"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179360365" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179360365">(Oct 29 2019 at 18:37)</a>:</h4>
<p>But they have very different impacts on the author of the function, of course.</p>



<a name="179360571"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179360571" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179360571">(Oct 29 2019 at 18:39)</a>:</h4>
<p>And, since <code>"C"</code> already exists in the language, we can't introduce a "safe-to-unwind" ABI and stabilize the desired abort-on-<code>unwind</code> behavior for <code>"C"</code> without having such an "implicit <code>nounwind</code>". That is maybe a good argument to add to Niko's document about the default behavior of <code>"C"</code>, but I don't really see it as a reason not to introduce <code>"C unwind"</code>.</p>



<a name="179361554"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179361554" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179361554">(Oct 29 2019 at 18:49)</a>:</h4>
<p>Note that we already have an equivalent of <code>noexcept</code> in (unstable) Rust: <code>#[unwind(aborts)]</code>. Literally the only difference is that it calls <code>intrinsics::trap</code> (Rust) instead of <code>std::terminate</code> (C++).</p>



<a name="179411652"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179411652" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179411652">(Oct 30 2019 at 08:41)</a>:</h4>
<p><span class="user-mention" data-user-id="143274">@Amanieu</span> the other difference is that <code>#[unwind(aborts)]</code> is not part of a function type</p>



<a name="179411658"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179411658" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179411658">(Oct 30 2019 at 08:41)</a>:</h4>
<p>So users can't really do any kind of type level reasoning about this</p>



<a name="179411727"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179411727" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179411727">(Oct 30 2019 at 08:42)</a>:</h4>
<p><span class="user-mention" data-user-id="120076">@Kyle Strand</span> i agree that the situation might be confusing, which is why I think that we should at least recognize the impact of <code>"C"</code> vs <code>"C unwind"</code> at that level, and be able to talk about it in this project group and its RFCs</p>



<a name="179411920"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179411920" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179411920">(Oct 30 2019 at 08:47)</a>:</h4>
<p>If you take a look at my first example here: <a href="#narrow/stream/210922-wg-ffi-unwind/topic/noexcept-like.20feature/near/178839302" title="#narrow/stream/210922-wg-ffi-unwind/topic/noexcept-like.20feature/near/178839302">https://rust-lang.zulipchat.com/#narrow/stream/210922-wg-ffi-unwind/topic/noexcept-like.20feature/near/178839302</a>, if we add <code>"C unwind"</code> and guarantee that <code>"C"</code> never unwinds I can use that trick to write code like this:</p>
<div class="codehilite"><pre><span></span><span class="k">trait</span><span class="w"> </span><span class="n">NeverUnwinds</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="c1">// manually expand this to multiple impls for different argument numbers:</span>
<span class="k">impl</span><span class="o">&lt;</span><span class="n">Ret</span><span class="p">,</span><span class="w"> </span><span class="n">Args</span><span class="p">...</span><span class="o">&gt;</span><span class="w"> </span><span class="n">NeverUnwinds</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="k">extern</span><span class="w"> </span><span class="s">&quot;C&quot;</span><span class="w"> </span><span class="k">fn</span><span class="p">(</span><span class="n">Args</span><span class="p">...)</span><span class="w"> </span>-&gt; <span class="nc">Ret</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>

<span class="cm">/* safe */</span><span class="w"> </span><span class="k">fn</span> <span class="nf">duplicate_map</span><span class="o">&lt;</span><span class="n">F</span><span class="o">&gt;</span><span class="p">(</span><span class="n">x</span>: <span class="kp">&amp;</span><span class="nc">mut</span><span class="w"> </span><span class="nb">Vec</span><span class="o">&lt;</span><span class="kt">i32</span><span class="o">&gt;</span><span class="p">,</span><span class="w"> </span><span class="n">map</span>: <span class="nc">F</span><span class="p">)</span><span class="w"></span>
<span class="k">where</span><span class="w"> </span><span class="n">F</span>: <span class="nb">Fn</span><span class="p">(</span><span class="kt">i32</span><span class="p">)</span>-&gt;<span class="kt">i32</span> <span class="o">+</span><span class="w"> </span><span class="n">NeverUnwinds</span><span class="w"></span>
<span class="p">{</span><span class="w"></span>
<span class="w">      </span><span class="k">unsafe</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">       </span><span class="c1">// safe because `map`is safe and it  never unwinds</span>
<span class="w">       </span><span class="c1">// no dropgurad, no catch_unwind</span>
<span class="w">       </span><span class="kd">let</span><span class="w"> </span><span class="n">new_len</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">x</span><span class="p">.</span><span class="n">len</span><span class="p">()</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mi">2</span><span class="p">;</span><span class="w"></span>
<span class="w">       </span><span class="n">x</span><span class="p">.</span><span class="n">reserve</span><span class="p">(</span><span class="n">new_len</span><span class="p">);</span><span class="w"></span>
<span class="w">       </span><span class="n">x</span><span class="p">.</span><span class="n">set_len</span><span class="p">(</span><span class="n">new_len</span><span class="p">);</span><span class="w"></span>
<span class="w">       </span><span class="k">for</span><span class="w"> </span><span class="p">...</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">ptr</span><span class="p">.</span><span class="n">write</span><span class="p">(...,</span><span class="w"> </span><span class="n">map</span><span class="p">(</span><span class="n">ptr</span><span class="p">.</span><span class="n">read</span><span class="p">(...))</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>


<p>that's a very poor's man <code>noexcept</code> feature, with the exact same power (except for <code>noexcept(expr)</code>), but worse ergonomics.</p>



<a name="179412073"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179412073" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179412073">(Oct 30 2019 at 08:50)</a>:</h4>
<p>While we are not adding this feature to enable this use case, it turns out that "by accident" this is a very powerful thing that the feature enables.</p>



<a name="179412098"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179412098" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179412098">(Oct 30 2019 at 08:51)</a>:</h4>
<p>I think that these super-powerful use-cases by accident are worth studying, e.g., C++ templates were not intended for meta-programming, yet here we are.</p>



<a name="179437858"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179437858" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179437858">(Oct 30 2019 at 14:34)</a>:</h4>
<p>How is that more powerful than <code>map: extern "C" fn(i32) -&gt; i32</code>? I don't see how the <code>NeverUnwindd</code> trait could be extended in any compile-checked way to other function-like types. For instance, <code>duplicate_map</code> itself could be made to not unwind by <code>abort</code>ing if the <code>reserve</code> triggers OOM, but I don't see how to encode that in any sort of compile-checked way.</p>



<a name="179438337"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179438337" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179438337">(Oct 30 2019 at 14:39)</a>:</h4>
<p>You are right, the <code>reserve</code> should be a: <code>assert!(capacity() &gt;= 2 * len())</code></p>



<a name="179438399"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179438399" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179438399">(Oct 30 2019 at 14:39)</a>:</h4>
<p>Ah wait, no, not necessarily, it is ok for reserve to panic</p>



<a name="179438442"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179438442" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179438442">(Oct 30 2019 at 14:40)</a>:</h4>
<p>so that is not a problem sorry</p>



<a name="179438462"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179438462" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179438462">(Oct 30 2019 at 14:40)</a>:</h4>
<p>the problem is <code>map</code> panicking after the <code>x.set_len</code> has been called</p>



<a name="179438477"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179438477" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179438477">(Oct 30 2019 at 14:40)</a>:</h4>
<p>that's the only thing that's required not to panic for correctness</p>



<a name="179438504"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179438504" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179438504">(Oct 30 2019 at 14:40)</a>:</h4>
<blockquote>
<p>I don't see how the NeverUnwindd trait could be extended in any compile-checked way to other function-like types.</p>
</blockquote>
<p>What do you mean ?</p>



<a name="179441776"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179441776" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179441776">(Oct 30 2019 at 15:10)</a>:</h4>
<p>It's not unsafe for it to panic in your example, but I'm talking about giving <code>duplicate_map</code> the <code>NeverUnwind</code> trait, in which case it <em>would</em> be unsafe for it to panic</p>



<a name="179441896"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179441896" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179441896">(Oct 30 2019 at 15:11)</a>:</h4>
<p>My point is that I don't see how this "poor man's <code>noexcept</code>" does anything except alias the <code>extern "C" fn</code> types</p>



<a name="179444626"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179444626" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179444626">(Oct 30 2019 at 15:35)</a>:</h4>
<p><span class="user-mention" data-user-id="120076">@Kyle Strand</span> the way to give <code>duplicate_map</code> the trait is just make it an <code>extern "C"</code> function</p>



<a name="179444752"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179444752" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179444752">(Oct 30 2019 at 15:36)</a>:</h4>
<p>in which case, I don't understand why you say that it would be unsafe for it to panic: if it panics, the program aborts, and the destructor of the vector is never run, but that doesn't matter because the invariant of the vector was not violated when reserve is called</p>



<a name="179444817"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179444817" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179444817">(Oct 30 2019 at 15:37)</a>:</h4>
<div class="codehilite"><pre><span></span><span class="cm">/* safe */</span><span class="w"> </span><span class="k">extern</span><span class="w"> </span><span class="s">&quot;C&quot;</span><span class="w"> </span><span class="k">fn</span> <span class="nf">duplicate_map_nounwind</span><span class="o">&lt;</span><span class="n">F</span><span class="o">&gt;</span><span class="p">(</span><span class="n">x</span>: <span class="kp">&amp;</span><span class="nc">mut</span><span class="w"> </span><span class="nb">Vec</span><span class="o">&lt;</span><span class="kt">i32</span><span class="o">&gt;</span><span class="p">,</span><span class="w"> </span><span class="n">map</span>: <span class="nc">F</span><span class="p">)</span><span class="w"></span>
<span class="k">where</span><span class="w"> </span><span class="n">F</span>: <span class="nb">Fn</span><span class="p">(</span><span class="kt">i32</span><span class="p">)</span>-&gt;<span class="kt">i32</span> <span class="o">+</span><span class="w"> </span><span class="n">NeverUnwinds</span><span class="w"></span>
<span class="p">{</span><span class="w"></span>
<span class="w">      </span><span class="k">unsafe</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">       </span><span class="c1">// safe because `map`is safe and it  never unwinds</span>
<span class="w">       </span><span class="c1">// no dropgurad, no catch_unwind</span>
<span class="w">       </span><span class="kd">let</span><span class="w"> </span><span class="n">new_len</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">x</span><span class="p">.</span><span class="n">len</span><span class="p">()</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="mi">2</span><span class="p">;</span><span class="w"></span>
<span class="w">       </span><span class="c1">// this can panic, and that&#39;s ok</span>
<span class="w">       </span><span class="n">x</span><span class="p">.</span><span class="n">reserve</span><span class="p">(</span><span class="n">new_len</span><span class="p">);</span><span class="w"></span>
<span class="w">       </span><span class="n">x</span><span class="p">.</span><span class="n">set_len</span><span class="p">(</span><span class="n">new_len</span><span class="p">);</span><span class="w"></span>
<span class="w">       </span><span class="k">for</span><span class="w"> </span><span class="p">...</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">ptr</span><span class="p">.</span><span class="n">write</span><span class="p">(...,</span><span class="w"> </span><span class="n">map</span><span class="p">(</span><span class="n">ptr</span><span class="p">.</span><span class="n">read</span><span class="p">(...))</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>



<a name="179445025"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179445025" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179445025">(Oct 30 2019 at 15:39)</a>:</h4>
<p>This means that <code>extern "C"</code> is now a "performance" feature.</p>



<a name="179445060"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179445060" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179445060">(Oct 30 2019 at 15:39)</a>:</h4>
<p>Just like people stamp <code>noexcept</code> everywhere in C++, people might want to stamp <code>extern "C"</code> everywhere in Rust</p>



<a name="179446197"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179446197" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179446197">(Oct 30 2019 at 15:49)</a>:</h4>
<p>If the <code>NeverUnwind</code> trait can _only ever_ apply to <code>extern "C" fn</code>, then no, we are not accidentally introducing a new "powerful" feature.</p>



<a name="179446253"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179446253" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179446253">(Oct 30 2019 at 15:49)</a>:</h4>
<p>If people want to modify many functions at once to <code>abort</code> instead of <code>panic</code>, the right way to do that is, of course, <code>panic = abort</code>.</p>



<a name="179446752"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179446752" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179446752">(Oct 30 2019 at 15:54)</a>:</h4>
<p>Conversely, if you're just saying that people will take applications that need to have unwinding somewhere in them and optimize them by adding <code>extern "C"</code> elsewhere, then we're back to my statement that this is "strictly an optimization".</p>



<a name="179447264"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179447264" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179447264">(Oct 30 2019 at 15:58)</a>:</h4>
<p>I will say that this all reminds me of something I was told by the LLVM dev I've mentioned before: "FFI isn't a sandbox"</p>



<a name="179447289"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179447289" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179447289">(Oct 30 2019 at 15:58)</a>:</h4>
<p>The full quote:</p>
<blockquote>
<p>If the callee can unwind, then it can unwind. FFI isn't a sandbox, it's not supposed to change behaviour or protect the caller. At the extreme I can recognize that some mapping of types is done in some systems (strings are a common one). On Linux, exceptions are primitive and well-defined much like 32-bit integers, despite the lack of support in C[1].</p>
<p>[1] - You can both throw and capture exceptions in C. The language doesn't define a syntax, but it doesn't need to. It doesn't define a syntax for networking or for threading either. Just include the header file and use the appropriate API.</p>
</blockquote>



<a name="179447550"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179447550" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179447550">(Oct 30 2019 at 16:00)</a>:</h4>
<p>....which would of course be an argument for allowing <code>extern "C"</code> to unwind by default (as <span class="user-mention" data-user-id="143274">@Amanieu</span> suggested), and _not_ introducing <code>"C unwind"</code> or <code>"C nounwind"</code>.</p>



<a name="179447765"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179447765" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179447765">(Oct 30 2019 at 16:02)</a>:</h4>
<p>My main concern there is that the claim is so Linux-specific, though it's true that SEH on Windows is also always useable even in C code.</p>



<a name="179510273"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179510273" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179510273">(Oct 31 2019 at 08:21)</a>:</h4>
<blockquote>
<p>If the NeverUnwind trait can _only ever_ apply to extern "C" fn, then no, we are not accidentally introducing a new "powerful" feature</p>
</blockquote>
<p>I disagree, since without <code>"C unwind"</code> people cannot write the <code>NeverUnwind</code> trait, but if we add <code>"C unwind"</code> to the language, they can.</p>
<blockquote>
<p>I will say that this all reminds me of something I was told by the LLVM dev I've mentioned before: "FFI isn't a sandbox"</p>
</blockquote>
<p>That quote is about FFI, while we are here talking about <code>noexcept</code> or LLVM's <code>nounwind</code> attribute.</p>



<a name="179520449"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179520449" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179520449">(Oct 31 2019 at 11:00)</a>:</h4>
<p>Thinking more about how to use it, another cool way to use this feature is:</p>
<div class="codehilite"><pre><span></span><span class="k">trait</span><span class="w"> </span><span class="n">NoUnwindCall</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">type</span> <span class="nc">Arg</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="k">type</span> <span class="nc">Ret</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="k">extern</span><span class="w"> </span><span class="s">&quot;C&quot;</span><span class="w"> </span><span class="k">fn</span> <span class="nf">nounwind_call</span><span class="p">(</span><span class="o">&amp;</span><span class="bp">self</span><span class="p">,</span><span class="w"> </span><span class="n">arg</span>: <span class="nc">Self</span>::<span class="n">Arg</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">Self</span>::<span class="n">Ret</span><span class="p">;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
<span class="k">impl</span><span class="o">&lt;</span><span class="n">Ret</span><span class="p">,</span><span class="w"> </span><span class="n">Arg</span><span class="p">...</span><span class="o">&gt;</span><span class="w"> </span><span class="n">NoUnwindCall</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="k">fn</span><span class="p">(</span><span class="n">Arg</span><span class="p">...)</span><span class="w"> </span>-&gt; <span class="nc">Ret</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">type</span> <span class="nc">Arg</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="n">Arg</span><span class="p">...);</span><span class="w"></span>
<span class="w">    </span><span class="k">type</span> <span class="nc">Ret</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">Ret</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="k">extern</span><span class="w"> </span><span class="s">&quot;C&quot;</span><span class="w"> </span><span class="k">fn</span> <span class="nf">nounwind_call</span><span class="p">(</span><span class="o">&amp;</span><span class="bp">self</span><span class="p">,</span><span class="w"> </span><span class="n">arg</span>: <span class="nc">Self</span>::<span class="n">Arg</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">Self</span>::<span class="n">Ret</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="bp">self</span><span class="p">(</span><span class="n">arg</span><span class="p">.</span><span class="mi">0</span><span class="p">,</span><span class="w"> </span><span class="p">...,</span><span class="w"> </span><span class="n">arg</span><span class="p">.</span><span class="n">N</span><span class="p">)</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>


<p>and now you can write:</p>
<div class="codehilite"><pre><span></span><span class="k">use</span><span class="w"> </span><span class="n">NoUnwindCall</span><span class="p">;</span><span class="w"></span>
<span class="k">fn</span> <span class="nf">foo</span><span class="p">(...)</span><span class="w"> </span>-&gt; <span class="p">...</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="p">...</span><span class="w"> </span><span class="n">Rust</span><span class="w"> </span><span class="n">ABI</span><span class="w"> </span><span class="n">function</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="kd">let</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">foo</span><span class="p">.</span><span class="n">nounwind_call</span><span class="p">((</span><span class="n">args</span><span class="p">...));</span><span class="w"></span>
</pre></div>


<p>to assert that a particular function call will not unwind. The only inconvenience is the ABI dance that this might incur.</p>



<a name="179534720"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179534720" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179534720">(Oct 31 2019 at 14:13)</a>:</h4>
<blockquote>
<p>Without <code>"C unwind"</code> people cannot write the <code>NeverUnwind</code> trait, but if we add <code>"C unwind"</code> to the language, they can.</p>
</blockquote>
<p>My point is that <code>NeverUnwind</code> is not particularly powerful, since there's no way to extend it to other types of functions, so it doesn't expose any abilities beyond what you'd get from using <code>extern "C"</code> directly. But, also, this has nothing to do with <code>"C unwind"</code> except insofar as the <em>already planned</em> change in behavior to make <code>extern "C"</code> abort-on-unwind hasn't yet been successfully stabilized because there was no way to opt out (which is what <code>unwind</code> would provide).</p>



<a name="179534883"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179534883" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179534883">(Oct 31 2019 at 14:15)</a>:</h4>
<blockquote>
<p>any abilities beyond what you'd get from using <code>extern "C"</code> directly...</p>
</blockquote>
<p>This is why I said above that <code>duplicate_map</code> could just take <code>map</code> as an <code>extern "C" fn</code> directly, since there's no other possible type that can implement that trait.</p>



<a name="179535048"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179535048" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179535048">(Oct 31 2019 at 14:16)</a>:</h4>
<p>Re: <code>NoUnwindCall</code>, that's just the equivalent of making an <code>extern "C"</code> lambda, but with a more confusing syntax.</p>



<a name="179535279"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179535279" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179535279">(Oct 31 2019 at 14:19)</a>:</h4>
<blockquote>
<p>That quote is about FFI, while we are here talking about <code>noexcept</code> or LLVM's <code>nounwind</code> attribute.</p>
</blockquote>
<p>Right, but your "ABI dance" is just abusing a feature intended for FFI to create such a "sandbox".</p>



<a name="179535981"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179535981" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179535981">(Oct 31 2019 at 14:26)</a>:</h4>
<p>I'll just repeat what I said before: <code>NeverUnwind</code> trait isn't that useful in practice because you can always use a drop guard instead, which allows you to accept any kind of callback, not just ones that never unwind. I don't think we should be basing our design decisions on a hypothetical trait which is almost never going to be used in practice.</p>



<a name="179543879"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179543879" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179543879">(Oct 31 2019 at 15:40)</a>:</h4>
<p><span class="user-mention" data-user-id="143274">@Amanieu</span> DropGuards do not let you tell the optimizer that a call does not unwind</p>



<a name="179543903"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179543903" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179543903">(Oct 31 2019 at 15:40)</a>:</h4>
<p>The problem NeverUnwind solves is the same problem that the <code>#[no_panic]</code> crate solves</p>



<a name="179543906"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179543906" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179543906">(Oct 31 2019 at 15:40)</a>:</h4>
<p>DropGuards have nothing to do with that</p>



<a name="179543972"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179543972" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179543972">(Oct 31 2019 at 15:41)</a>:</h4>
<p><span class="user-mention" data-user-id="120076">@Kyle Strand</span> </p>
<blockquote>
<p>But, also, this has nothing to do with "C unwind" except insofar as the already planned change in behavior to make extern "C" abort-on-unwind hasn't yet been successfully stabilized because there was no way to opt out (which is what unwind would provide).</p>
</blockquote>
<p>Right now one cannot assume that an <code>extern "C"</code> function never unwinds. The <code>"C unwind"</code> proposal  _guarantees_ that <code>extern "C"</code> functions never unwind.</p>



<a name="179544056"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179544056" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179544056">(Oct 31 2019 at 15:42)</a>:</h4>
<p>No, those are separate. The <code>"C unwind"</code> proposal is partly _motivated_ by the fact that we've previously been unable to specify the already-planned never-unwind behavior.</p>



<a name="179544084"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179544084" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179544084">(Oct 31 2019 at 15:42)</a>:</h4>
<p>But the <code>"C unwind"</code> proposal does not _introduce_ that idea.</p>



<a name="179544092"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179544092" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179544092">(Oct 31 2019 at 15:42)</a>:</h4>
<p>Not in <span class="user-mention" data-user-id="116009">@nikomatsakis</span> RFC, which starts by saying that we insert abort-on-panic shims for <code>extern "C"</code> functions (that's the first thing that RFC changes in the language, and what enables <code>NeverUnwind</code> above).</p>



<a name="179544296"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179544296" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179544296">(Oct 31 2019 at 15:44)</a>:</h4>
<p>A different RFC might say that <code>extern "C"</code> functions can unwind just fine, and do not provide any way to make a function <code>nounwind</code>, making it impossible for <code>NeverUnwind</code> to be written in Rust.</p>



<a name="179544330"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179544330" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179544330">(Oct 31 2019 at 15:44)</a>:</h4>
<p>Right now both options are on the table, the <code>"C unwind"</code> RFC picks one of them.</p>



<a name="179544379"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179544379" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179544379">(Oct 31 2019 at 15:45)</a>:</h4>
<p>...right, with a link to a <code>rust</code> issue stating that the behavior was originally introduced in Rust 1.24.</p>



<a name="179544545"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179544545" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179544545">(Oct 31 2019 at 15:46)</a>:</h4>
<p>If that was really the case, allowing <code>extern "C"</code> to unwind would be a breaking change</p>



<a name="179544561"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179544561" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179544561">(Oct 31 2019 at 15:46)</a>:</h4>
<p>I.e., that is not a change to the <em>intended</em> defined-behavior of <code>extern "C"</code>; it just <em>implements</em> that behavior and makes it no longer undefined.</p>



<a name="179544604"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179544604" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179544604">(Oct 31 2019 at 15:46)</a>:</h4>
<p>Yes, Rust 1.24.1 has a breaking change from 1.24.0</p>



<a name="179544644"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179544644" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179544644">(Oct 31 2019 at 15:47)</a>:</h4>
<p>IIUC, Rust 1.24.0 still said that unwinding from an extern "C" function is UB</p>



<a name="179544662"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179544662" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179544662">(Oct 31 2019 at 15:47)</a>:</h4>
<p>it did not provide any guarantees</p>



<a name="179544672"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179544672" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179544672">(Oct 31 2019 at 15:47)</a>:</h4>
<p>it just implemented that UB to abort</p>



<a name="179544715"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179544715" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179544715">(Oct 31 2019 at 15:48)</a>:</h4>
<p><a href="https://blog.rust-lang.org/2018/02/15/Rust-1.24.html#other-good-stuff" target="_blank" title="https://blog.rust-lang.org/2018/02/15/Rust-1.24.html#other-good-stuff">https://blog.rust-lang.org/2018/02/15/Rust-1.24.html#other-good-stuff</a></p>



<a name="179544749"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179544749" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179544749">(Oct 31 2019 at 15:48)</a>:</h4>
<blockquote>
<p>In Rust 1.24, this code will now abort instead of producing undefined behavior.</p>
</blockquote>



<a name="179544793"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179544793" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179544793">(Oct 31 2019 at 15:48)</a>:</h4>
<p>Indeed. Well then this feature is already in the language, and allowing <code>extern "C"</code> to unwind isn't on the table</p>



<a name="179544800"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179544800" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179544800">(Oct 31 2019 at 15:48)</a>:</h4>
<p>....</p>



<a name="179544827"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179544827" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179544827">(Oct 31 2019 at 15:49)</a>:</h4>
<p>the unwind behavior was <em>immediately</em> restored in 1.24.1</p>



<a name="179544852"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179544852" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179544852">(Oct 31 2019 at 15:49)</a>:</h4>
<p>so... then the <code>"C unwind"</code> rfc introduces this feature in the language</p>



<a name="179544854"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179544854" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179544854">(Oct 31 2019 at 15:49)</a>:</h4>
<p>because 1.24.0 broke actual existing code</p>



<a name="179544918"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179544918" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179544918">(Oct 31 2019 at 15:50)</a>:</h4>
<p>I believe my original wording was "permits stabilizing" that behavior. We can restore that verbiage if it's clearer.</p>



<a name="179544989"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179544989" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179544989">(Oct 31 2019 at 15:50)</a>:</h4>
<p>You are confusing me. Either this feature is in the language already or not. And if it isn't, either <code>"C unwind"</code> introduces it or not.</p>



<a name="179545027"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179545027" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179545027">(Oct 31 2019 at 15:50)</a>:</h4>
<p>My original claim is that right now it isn't in the language, and the <code>"C unwind"</code> RFC introduces it.</p>



<a name="179545075"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179545075" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179545075">(Oct 31 2019 at 15:51)</a>:</h4>
<p>The <em>plan</em> has been in the language for a long, long, long time. Because there's only one implementation and we don't have a formal spec, whether or not a planned feature is "in the language" is a bit of a hazy question, I think.</p>



<a name="179545209"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179545209" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179545209">(Oct 31 2019 at 15:52)</a>:</h4>
<p>But, yes, if the "C unwind" RFC (in its final form, not its draft form) says something like "we stabilize the unwind-on-abort behavior", then yes, once the RFC spec is actually implemented, that will be a breaking change.</p>



<a name="179545226"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179545226" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179545226">(Oct 31 2019 at 15:52)</a>:</h4>
<p>it's not a breaking change</p>



<a name="179545238"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179545238" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179545238">(Oct 31 2019 at 15:52)</a>:</h4>
<p>right now the behavior is undefined</p>



<a name="179545246"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179545246" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179545246">(Oct 31 2019 at 15:52)</a>:</h4>
<p>defining undefined behavior is not a breaking change</p>



<a name="179545288"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179545288" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179545288">(Oct 31 2019 at 15:52)</a>:</h4>
<p>I disagree. Wasmer and Lucet have relied on that behavior.</p>



<a name="179545330"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179545330" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179545330">(Oct 31 2019 at 15:53)</a>:</h4>
<p>They know about it, and they can upgrade to "C unwind" afterwards</p>



<a name="179545340"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179545340" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179545340">(Oct 31 2019 at 15:53)</a>:</h4>
<p>So, changing it breaks the functionality of their previously-working code, <em>regardless</em> of whether their previously-working code was "guaranteed" by the Rust Reference to work.</p>



<a name="179545344"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179545344" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179545344">(Oct 31 2019 at 15:53)</a>:</h4>
<p>RIght.</p>



<a name="179545369"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179545369" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179545369">(Oct 31 2019 at 15:53)</a>:</h4>
<p>Because we'd be changing the behavior of <code>extern "C"</code> in the implementation.</p>



<a name="179545488"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179545488" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179545488">(Oct 31 2019 at 15:54)</a>:</h4>
<p>I disagree, that code is already broken.</p>



<a name="179545497"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179545497" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179545497">(Oct 31 2019 at 15:54)</a>:</h4>
<p>And has always been.</p>



<a name="179545515"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179545515" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179545515">(Oct 31 2019 at 15:54)</a>:</h4>
<p>I'm not going to re-hash that argument here; it was pretty played out in the original thread about <code>mozjpeg</code>.</p>



<a name="179545537"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179545537" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179545537">(Oct 31 2019 at 15:55)</a>:</h4>
<p>Which is why i don't know why you are bringing it up again.</p>



<a name="179545564"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179545564" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179545564">(Oct 31 2019 at 15:55)</a>:</h4>
<p>The point is: the design for <code>extern "C unwind"</code> does not necessarily imply the behavior of <code>extern "C"</code>. For the last several years, the lang team has been consistent in stating that the <em>desired</em> behavior for <code>extern "C"</code> to have "someday" is abort-on-unwind.</p>



<a name="179545595"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179545595" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179545595">(Oct 31 2019 at 15:55)</a>:</h4>
<p>You claim that defining undefined behavior is a breaking change. The logical consequence of that is that we cannot define undefined behavior, and therefore, we can't change <code>extern "C"</code> to anything (neither allow unwinding, nor disallow it).</p>



<a name="179545728"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179545728" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179545728">(Oct 31 2019 at 15:57)</a>:</h4>
<p>I disagree with the claim, and the logical consequence of that is that we can define the behavior of <code>extern "C"</code> to whatever we want.</p>



<a name="179545766"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179545766" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179545766">(Oct 31 2019 at 15:57)</a>:</h4>
<p>The main issue was that <code>#[unwind(allowed)]</code> was still unstable, which mean there was no way for people to fix their code to no longer make it UB.</p>



<a name="179545835"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179545835" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179545835">(Oct 31 2019 at 15:58)</a>:</h4>
<p>Sure, but that's a practical issue orthogonal to whether "defining UB to something" is a breaking change or not.</p>



<a name="179545886"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179545886" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179545886">(Oct 31 2019 at 15:59)</a>:</h4>
<p>Just because we can define the behavior of <code>extern "C"</code> from undefined to something else does not mean that we should do it, e.g., until a different feature is added to the language.</p>



<a name="179545908"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179545908" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179545908">(Oct 31 2019 at 15:59)</a>:</h4>
<p>I think there are a couple logical leaps there, but in any case that's beside the point. All I'm trying to say is that, until an RFC saying otherwise lands, we can still decide not to stabilize <code>extern "C"</code>'s abort-on-unwind behavior, <em>independently</em> of introducing the <code>extern "C unwind"</code> feature.</p>



<a name="179546011"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179546011" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179546011">(Oct 31 2019 at 16:00)</a>:</h4>
<p>Sure, we could change the <code>"C unwind"</code> RFC to not guarantee that <code>extern "C"</code> panics on abort, that prevents <code>NeverUnwinds</code> from working</p>



<a name="179546061"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179546061" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179546061">(Oct 31 2019 at 16:00)</a>:</h4>
<p>Therefore, it is not true the <code>extern "C unwind"</code> introduces the "noexcept" concept; it <em>is</em> true that the <em>currently planned guarantee</em> for <code>extern "C"</code> would introduce the "noexcept" concept (though, again, I think it's much weaker than you've stated above).</p>



<a name="179546153"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179546153" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179546153">(Oct 31 2019 at 16:01)</a>:</h4>
<p>I'm not sure where you are going. Do you want to remove the abort-on-panic guarantee from the <code>"C unwind"</code> RFC?</p>



<a name="179546238"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179546238" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179546238">(Oct 31 2019 at 16:02)</a>:</h4>
<p>This is why I want to know what Centril thinks of the "FFI is not a sandbox" quote. The lang team has been planning (since long before I got involved with this effort) to make <code>extern "C"</code> abort-on-unwind, which, as you're now pointing out, creates a less-powerful <code>noexcept</code>-like feature. If the lang team thinks this is an okay thing to introduce this way, well, okay. If this is something they hadn't considered before and makes them reconsider the abort-on-unwind issue, that's also okay.</p>



<a name="179546274"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179546274" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179546274">(Oct 31 2019 at 16:03)</a>:</h4>
<blockquote>
<p>again, I think it's much weaker than you've stated above</p>
</blockquote>
<p>What does<code>noexcept</code> allow that <code>extern "C"</code> does not ?</p>



<a name="179546310"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179546310" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179546310">(Oct 31 2019 at 16:03)</a>:</h4>
<p>You can apply it to <code>Fn</code>s, not just <code>fn</code>s, for one</p>



<a name="179546348"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179546348" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179546348">(Oct 31 2019 at 16:03)</a>:</h4>
<p>(Or at least, I would expect it to be designed in such a way)</p>



<a name="179546364"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179546364" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179546364">(Oct 31 2019 at 16:04)</a>:</h4>
<p><code>extern "C" fn foo&lt;F: Fn(...) -&gt; ...&gt;(f: F) -&gt; ... { f(...) }</code></p>



<a name="179546424"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179546424" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179546424">(Oct 31 2019 at 16:04)</a>:</h4>
<p>You can trivially wrap <code>Fn</code> traits in <code>extern "C"</code> functions to apply it.</p>



<a name="179546431"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179546431" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179546431">(Oct 31 2019 at 16:04)</a>:</h4>
<p>Again, that might as well be a lambda</p>



<a name="179546451"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179546451" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179546451">(Oct 31 2019 at 16:04)</a>:</h4>
<p>That's what <a href="#narrow/stream/210922-wg-ffi-unwind/topic/noexcept-like.20feature/near/179520449" title="#narrow/stream/210922-wg-ffi-unwind/topic/noexcept-like.20feature/near/179520449">https://rust-lang.zulipchat.com/#narrow/stream/210922-wg-ffi-unwind/topic/noexcept-like.20feature/near/179520449</a> does</p>



<a name="179546456"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179546456" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179546456">(Oct 31 2019 at 16:04)</a>:</h4>
<p>But, yes, it allows such wrapping</p>



<a name="179546489"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179546489" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179546489">(Oct 31 2019 at 16:05)</a>:</h4>
<blockquote>
<p>That's what <a href="#narrow/stream/210922-wg-ffi-unwind/topic/noexcept-like.20feature/near/179520449" title="#narrow/stream/210922-wg-ffi-unwind/topic/noexcept-like.20feature/near/179520449">https://rust-lang.zulipchat.com/#narrow/stream/210922-wg-ffi-unwind/topic/noexcept-like.20feature/near/179520449</a> does</p>
</blockquote>
<p>Yes, I remember, and I responded there!</p>



<a name="179546554"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179546554" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179546554">(Oct 31 2019 at 16:05)</a>:</h4>
<blockquote>
<p>Again, that might as well be a lambda</p>
</blockquote>
<p>Do you have a playground link? <code>extern "C" | ... | ...</code> is invalid syntax.</p>



<a name="179546668"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179546668" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179546668">(Oct 31 2019 at 16:06)</a>:</h4>
<p>Or do you mean that the lambda can coerce to an <code>extern "C" fn</code> type if it captures no environment ?</p>



<a name="179546722"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179546722" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179546722">(Oct 31 2019 at 16:07)</a>:</h4>
<p>(notice that the trait works for closures with an environment)</p>



<a name="179546884"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179546884" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179546884">(Oct 31 2019 at 16:08)</a>:</h4>
<p>I was thinking of something else from the RFC draft, about converting different ABIs to each other:</p>
<div class="codehilite"><pre><span></span>It is
252-not possible, for example, to cast a `extern &quot;C&quot; fn()` value into a `extern &quot;C
253-unwind&quot; fn()` value. It is however possible to convert between ABIs by using a
254-closure expression (which is then coerced into a standalone function):
255-
256-```rust
257-fn convert(f: extern &quot;C&quot; fn()) -&gt; extern &quot;C unwind&quot; fn() {
258:    return || f();
259-}
260-```
</pre></div>



<a name="179547076"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179547076" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179547076">(Oct 31 2019 at 16:10)</a>:</h4>
<p>Yes, that works, but requires the lambda to have no environment.</p>



<a name="179547080"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179547080" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179547080">(Oct 31 2019 at 16:10)</a>:</h4>
<p>Obviously you'd change the signature, from <code>extern "C" fn -&gt; extern "C unwind fn</code> to <code>Fn -&gt; extern "C" fn</code>, but it's the same idea</p>



<a name="179547092"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179547092" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179547092">(Oct 31 2019 at 16:10)</a>:</h4>
<p>Fair enough.</p>



<a name="179547098"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179547098" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179547098">(Oct 31 2019 at 16:10)</a>:</h4>
<p>The trait works even if the lambda captures an environment, it works for all Fn traits in general</p>



<a name="179547141"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179547141" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179547141">(Oct 31 2019 at 16:11)</a>:</h4>
<p>The problem I mentioned is that both the trait and the coercion need to "adapt" the ABIs</p>



<a name="179547177"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179547177" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179547177">(Oct 31 2019 at 16:11)</a>:</h4>
<p><code>fn convert(f: extern "Rust" fn()) -&gt; extern "C unwind" fn() { || f() }</code> needs to adapt the Rust ABI (or any other) to the <code>"C unwind"</code> ABI</p>



<a name="179547199"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179547199" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179547199">(Oct 31 2019 at 16:11)</a>:</h4>
<p>Right...</p>



<a name="179547259"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179547259" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179547259">(Oct 31 2019 at 16:12)</a>:</h4>
<p>so you end up with an ABI dance that hopefully LLVM removes, but its at least in the language</p>



<a name="179547296"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179547296" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179547296">(Oct 31 2019 at 16:12)</a>:</h4>
<p>A proper <code>noexcept</code> feature removes this, but that's the only thing I can think of in which they differ.</p>



<a name="179547323"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179547323" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179547323">(Oct 31 2019 at 16:13)</a>:</h4>
<p>That makes <code>extern "C"</code> only slightly less powerful than <code>noexcept</code> in my eyes, unless I'm missing other differences. A lot less ergonomic though.</p>



<a name="179547359"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179547359" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179547359">(Oct 31 2019 at 16:13)</a>:</h4>
<p>Anyway: I don't really have an opinion on whether introducing the panic-on-abort logic in <code>extern "C"</code> is a great idea. Again, that's why I want the lang team to weigh in on it, since they've been planning it for a <em>long</em> time. If they're committed to it, I don't think it matters one way or the other whether it stabilizes as part of the <code>extern "C unwind"</code> RFC or separately.</p>



<a name="179547478"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179547478" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179547478">(Oct 31 2019 at 16:14)</a>:</h4>
<p>It kind of needs to either stabilize at the same time as <code>"C unwind"</code> or afterwards, because otherwise Lucene breaks without an easy migration path.</p>



<a name="179547495"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179547495" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179547495">(Oct 31 2019 at 16:14)</a>:</h4>
<p>Right, it's the "or afterwards" on which I have no opinion</p>



<a name="179547545"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179547545" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179547545">(Oct 31 2019 at 16:15)</a>:</h4>
<p>It's kind of weird to add a <code>"C unwind"</code> ABI while reserving the right to allow <code>"C"</code> to unwind</p>



<a name="179547610"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179547610" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179547610">(Oct 31 2019 at 16:16)</a>:</h4>
<p><span aria-label="shrug" class="emoji emoji-1f937" role="img" title="shrug">:shrug:</span></p>



<a name="179547650"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179547650" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179547650">(Oct 31 2019 at 16:16)</a>:</h4>
<p>I don't think it's that weird, because <code>"C unwind"</code> is more explicit and will have well-defined behavior.</p>



<a name="179547711"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179547711" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179547711">(Oct 31 2019 at 16:17)</a>:</h4>
<p>If "C" is defined to allow unwinding, then it has defined behavior as well, and current code works correctly without changes.</p>



<a name="179547716"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179547716" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179547716">(Oct 31 2019 at 16:18)</a>:</h4>
<p>....right</p>



<a name="179547767"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179547767" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179547767">(Oct 31 2019 at 16:18)</a>:</h4>
<p>So I think it does make sense to do both as part of the same RFC.</p>



<a name="179547772"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179547772" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179547772">(Oct 31 2019 at 16:18)</a>:</h4>
<p>that's...fine</p>



<a name="179547779"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179547779" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179547779">(Oct 31 2019 at 16:18)</a>:</h4>
<p>again, I have no opinion</p>



<a name="179547787"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179547787" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179547787">(Oct 31 2019 at 16:18)</a>:</h4>
<p>Otherwise its kind of a bit of a big unresolved question.</p>



<a name="179547849"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179547849" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179547849">(Oct 31 2019 at 16:19)</a>:</h4>
<p>Leaving questions unresolved in the language spec but promising to resolve them eventually is very nearly the entire purpose of this group!</p>



<a name="179548017"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179548017" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179548017">(Oct 31 2019 at 16:20)</a>:</h4>
<p>I think C++'s approach of letting <code>extern "C"</code> functions unwind is entirely reasonable. If the <code>mozjpeg</code> discussion had led to the language team agreeing with this position, and deciding to let <code>extern "C"</code> functions unwind and not consider them UB, then yeah, we wouldn't need <code>"C unwind"</code>. But that's not where we are right now.</p>



<a name="179548083"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179548083" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179548083">(Oct 31 2019 at 16:21)</a>:</h4>
<p>Again, that's why I added the "FFI is not a sandbox" quote to Niko's HackMD doc, and why I'm saying that this is a discussion that needs to be had with the lang team.</p>



<a name="179548366"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179548366" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179548366">(Oct 31 2019 at 16:24)</a>:</h4>
<p>This WG is a sub-group of the lang team, so its kind of natural to discuss these here and prepare summaries for lang team discussion</p>



<a name="179548447"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179548447" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179548447">(Oct 31 2019 at 16:25)</a>:</h4>
<p>I'm not aware of anyone raising the issue that we are technically adding 99% of a <code>noexcept</code> feature to the language, just limited to the <code>"C"</code> abi, and less ergonomic to use, but adding the same kind of power</p>



<a name="179548849"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179548849" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179548849">(Oct 31 2019 at 16:29)</a>:</h4>
<p>Okay, would you like to add that to the HackMD issue yourself?</p>



<a name="179548881"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179548881" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179548881">(Oct 31 2019 at 16:29)</a>:</h4>
<p>Sure, where is it ?</p>



<a name="179548902"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179548902" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179548902">(Oct 31 2019 at 16:29)</a>:</h4>
<p><a href="https://hackmd.io/ymsEL6OpR6OSMoFr1As1rw?view" target="_blank" title="https://hackmd.io/ymsEL6OpR6OSMoFr1As1rw?view">https://hackmd.io/ymsEL6OpR6OSMoFr1As1rw?view</a></p>



<a name="179548974"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179548974" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179548974">(Oct 31 2019 at 16:30)</a>:</h4>
<p>I'll let you know when I add it so that you can check if I presented your arguments accurately</p>



<a name="179549020"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179549020" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179549020">(Oct 31 2019 at 16:30)</a>:</h4>
<p>AFAIK, the only lang team member who is somewhat active in this group who (if I remember correctly) was strongly against letting <code>extern "C"</code> unwind is Centril. I think he would be the one to talk to about whether he thinks this is a compelling reason to change course on the planned <code>extern "C"</code> behavior.</p>



<a name="179549068"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179549068" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179549068">(Oct 31 2019 at 16:31)</a>:</h4>
<p><span class="user-mention" data-user-id="132920">@gnzlbg</span> Don't worry about presenting my arguments accurately; just explain why <code>extern "C"</code> is an implicit <code>noexcept</code>, and why you think that's a concern.</p>



<a name="179549096"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179549096" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179549096">(Oct 31 2019 at 16:31)</a>:</h4>
<p>I still think that's essentially the same argument being made in the section I added at the bottom, about FFI being a "sandbox", so feel free to add it there, or add a new section, as you see fit.</p>



<a name="179549565"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179549565" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179549565">(Oct 31 2019 at 16:36)</a>:</h4>
<p>My personal feeling is ambivalent: I'll just update my code according to whatever is decided.</p>



<a name="179552403"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179552403" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179552403">(Oct 31 2019 at 17:02)</a>:</h4>
<blockquote>
<p>Don't worry about presenting my arguments accurately; just explain why extern "C" is an implicit noexcept, and why you think that's a concern.</p>
</blockquote>
<p><span class="user-mention" data-user-id="120076">@Kyle Strand</span> ok I;ve done that in the last subsection, as an argument against making <code>extern "C"</code> never unwind by default</p>



<a name="179552650"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/179552650" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#179552650">(Oct 31 2019 at 17:05)</a>:</h4>
<p>Thanks!</p>



<a name="180597308"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180597308" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180597308">(Nov 13 2019 at 06:54)</a>:</h4>
<p>I've finally caught up with this great. <span aria-label="slight smile" class="emoji emoji-1f642" role="img" title="slight smile">:slight_smile:</span></p>
<p><span class="user-mention" data-user-id="120076">@Kyle Strand</span> I see that I've been mentioned a few times. Feel free to ping me if you want my input.</p>



<a name="180597314"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180597314" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180597314">(Nov 13 2019 at 06:54)</a>:</h4>
<p>I've left some comments in the HackMD; so far it has enhanced my belief that <code>nounwind</code> for <code>extern "C"</code> is the right default</p>



<a name="180597940"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180597940" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180597940">(Nov 13 2019 at 07:04)</a>:</h4>
<p>Some other points:</p>
<p>- I agree that <code>NeverUnwinds</code> adds no more expressive power than <code>extern "C"</code> already affords one way or the other. It is indeed an alias.</p>
<p>- I cannot tell whether <span class="user-mention" data-user-id="132920">@gnzlbg</span>  is arguing for or against <code>nounwind</code> by default by discussing <code>NeverUnwinds</code>. To me, however, it would be an advantage if I can use <code>extern "C"</code> to encode higher order functions where I know that the passed-in function cannot unwind. The fact that there might be desirable generalizations in terms of <code>impl nopanic Fn(..)</code> does not, in my view, negate that advantage. A generalization having short-hands for the common case isn't a bad thing in language design.</p>
<p>- Further to ^-, we should, in my view, clarify whether we allow negative reasoning wrt. <code>extern "C"</code> having <code>nounwind</code> being UB. I think it would be useful to allow such negative reasoning <em>in this case</em>.</p>
<p>- The use of "breaking change" in this thread has been ambiguous on both <span class="user-mention" data-user-id="132920">@gnzlbg</span>'s and <span class="user-mention" data-user-id="120076">@Kyle Strand</span>'s ends. We can think of "breaking" in the sense of RFC 1122 or in "breaking in practice". In the former sense, we all agree that unwinding through <code>extern "C"</code> is UB. In the latter sense, despite explicit documentation in the reference to the contrary and LLVM UB, some people rely on the UB not to cause mis-compilations. It's clear to me that we are allowed to break those clients, but this WG exists because to resolve the soundness issue of <code>extern "C" fn foo(...) { ... }</code> we need to offer an alternative before we re-add the abort shim.</p>
<p>- Further to ^--, we must add the abort shim for <code>extern "C" fn foo() { ... }</code> or remove <code>nounwind</code> in LLVM. For the purposes of soundness, this is a binary choice.</p>



<a name="180598344"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180598344" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180598344">(Nov 13 2019 at 07:12)</a>:</h4>
<p><span class="user-mention" data-user-id="126931">@centril</span> I’m not arguing against or in favor of nounwind by default, just trying to point out that no matter which syntax we use and how we try to limit it, we probably end up adding a NeverUnwinds kind of capability to the language that doesn’t exist today. Instead of doing that „by accident“ it might be worth it to step back and consider doing that „by design“.</p>



<a name="180598371"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180598371" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180598371">(Nov 13 2019 at 07:13)</a>:</h4>
<p><span class="user-mention" data-user-id="132920">@gnzlbg</span> Ok, so you are neutral and would like more deliberation on this; very fair.  But what does "by design" entail?</p>



<a name="180598382"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180598382" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180598382">(Nov 13 2019 at 07:13)</a>:</h4>
<p>There was also the possibility of allowing all extern “C” functions to unwind, and figure out later how to specify that some do not unwind. That solution doesn’t add a NeverUnwinds capability to the language.</p>



<a name="180598383"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180598383" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180598383">(Nov 13 2019 at 07:13)</a>:</h4>
<p>it could mean designing an effect system, but that's is comparatively hugely more complicated than a mere ABI string from the POV of the type system</p>



<a name="180598430"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180598430" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180598430">(Nov 13 2019 at 07:14)</a>:</h4>
<p>We already have const, async, target feature, ...</p>



<a name="180598440"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180598440" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180598440">(Nov 13 2019 at 07:14)</a>:</h4>
<p>We could add another nounwind qualifier</p>



<a name="180598444"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180598444" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180598444">(Nov 13 2019 at 07:14)</a>:</h4>
<p>But there are many trade offs involved</p>



<a name="180598468"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180598468" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180598468">(Nov 13 2019 at 07:15)</a>:</h4>
<p><span class="user-mention" data-user-id="132920">@gnzlbg</span> yes, but note that const functions cannot be polymorphic yet, and if they are, we haven't decided to add e.g. <code>arg: impl const Fn()</code> which isn't just polymorphic but "must" be passed-in a <code>const fn</code></p>



<a name="180598479"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180598479" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180598479">(Nov 13 2019 at 07:15)</a>:</h4>
<p>async higher order functions aren't a thing either</p>



<a name="180598529"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180598529" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180598529">(Nov 13 2019 at 07:16)</a>:</h4>
<p>These trade offs might not be worth solving right now. We could just allow all extern “C” to unwind and provide an FFI only attribute to specify that some unknown ones are known to not unwind</p>



<a name="180598530"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180598530" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180598530">(Nov 13 2019 at 07:16)</a>:</h4>
<p>I agree that abstracting over effects would be useful, but I'm not the only one to convince</p>



<a name="180598532"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180598532" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180598532">(Nov 13 2019 at 07:16)</a>:</h4>
<p>But don’t reflect that on the ABI</p>



<a name="180598539"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180598539" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180598539">(Nov 13 2019 at 07:16)</a>:</h4>
<p>Avoiding NeverUnwinds</p>



<a name="180598545"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180598545" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180598545">(Nov 13 2019 at 07:16)</a>:</h4>
<p>In Rust, LLVM automatically infers nounwind anyways</p>



<a name="180598550"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180598550" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180598550">(Nov 13 2019 at 07:17)</a>:</h4>
<p><span class="user-mention" data-user-id="132920">@gnzlbg</span> I don't see much gain in delaying solving that; it's not like preventing <code>NeverUnwinds</code> is a useful goal (imo)</p>



<a name="180598552"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180598552" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180598552">(Nov 13 2019 at 07:17)</a>:</h4>
<p>So for an Exeter “C” defined in Rust this attribute isn’t necessary</p>



<a name="180598561"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180598561" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180598561">(Nov 13 2019 at 07:17)</a>:</h4>
<p>and I have not been convinced that changing the defaults is the right move</p>



<a name="180598564"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180598564" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180598564">(Nov 13 2019 at 07:17)</a>:</h4>
<p>I think that having NeverUnwinds only work for extern C is bad</p>



<a name="180598577"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180598577" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180598577">(Nov 13 2019 at 07:17)</a>:</h4>
<p>It requires juggling between the Rust and the C ABI all the time</p>



<a name="180598581"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180598581" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180598581">(Nov 13 2019 at 07:17)</a>:</h4>
<p>For no reason</p>



<a name="180598622"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180598622" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180598622">(Nov 13 2019 at 07:18)</a>:</h4>
<p>I agree as well it would be useful, but it is a big hack</p>



<a name="180598635"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180598635" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180598635">(Nov 13 2019 at 07:18)</a>:</h4>
<p>I don't think users would be encouraged to somehow sprinkle <code>extern "C" fn</code> in HoFs all of a sudden</p>



<a name="180598644"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180598644" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180598644">(Nov 13 2019 at 07:18)</a>:</h4>
<p>A proper solution might be easier if all ABI strings would behave similarly wrt unwinding</p>



<a name="180598656"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180598656" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180598656">(Nov 13 2019 at 07:19)</a>:</h4>
<p>we could also split things into <code>extern "C", "unwind"</code> and now allow <code>extern "Rust", "unwind"</code> -- that's still a cheap solution wrt. spec and compiler internals</p>



<a name="180598659"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180598659" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180598659">(Nov 13 2019 at 07:19)</a>:</h4>
<p>very cheap in fact</p>



<a name="180598708"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180598708" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180598708">(Nov 13 2019 at 07:20)</a>:</h4>
<p>Rust is unwind by default, if C is nounwind by default, we’d need both “unwind” and “nounwind”</p>



<a name="180598716"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180598716" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180598716">(Nov 13 2019 at 07:20)</a>:</h4>
<p>sure</p>



<a name="180598719"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180598719" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180598719">(Nov 13 2019 at 07:20)</a>:</h4>
<p>not a problem imo</p>



<a name="180598721"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180598721" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180598721">(Nov 13 2019 at 07:20)</a>:</h4>
<p>Imagine if extern “C” functions were const fn by default</p>



<a name="180598724"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180598724" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180598724">(Nov 13 2019 at 07:20)</a>:</h4>
<p>still very cheap</p>



<a name="180598728"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180598728" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180598728">(Nov 13 2019 at 07:20)</a>:</h4>
<p>We’d be in a bit more trouble with traits</p>



<a name="180598741"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180598741" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180598741">(Nov 13 2019 at 07:21)</a>:</h4>
<p>E.g need to implement !const trait impls for extern “C”</p>



<a name="180598752"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180598752" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180598752">(Nov 13 2019 at 07:21)</a>:</h4>
<p>We can also say that extern “C” functions don’t unwind by default</p>



<a name="180598755"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180598755" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180598755">(Nov 13 2019 at 07:21)</a>:</h4>
<blockquote>
<p>Imagine if extern “C” functions were const fn by default</p>
</blockquote>
<p>That might have made sense if <code>const fn</code> was the default and we had <code>io fn</code> for adding the effect instead of stripping away from the base effect</p>



<a name="180598756"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180598756" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180598756">(Nov 13 2019 at 07:21)</a>:</h4>
<p>Unknown ones</p>



<a name="180598798"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180598798" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180598798">(Nov 13 2019 at 07:22)</a>:</h4>
<p>@centril but for Rust it would be different than for extern C</p>



<a name="180598806"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180598806" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180598806">(Nov 13 2019 at 07:22)</a>:</h4>
<p>The point isn’t what default makes sense, but having different defaults for const depending on the ABI</p>



<a name="180598813"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180598813" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180598813">(Nov 13 2019 at 07:22)</a>:</h4>
<p>I don't think there's anything inherently wrong with having different defaults</p>



<a name="180598815"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180598815" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180598815">(Nov 13 2019 at 07:22)</a>:</h4>
<p>I think that it is possible for extern “C” to allow unwinding</p>



<a name="180598824"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180598824" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180598824">(Nov 13 2019 at 07:23)</a>:</h4>
<p>And for unknown extern “C” functions to be nounwind by default</p>



<a name="180598829"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180598829" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180598829">(Nov 13 2019 at 07:23)</a>:</h4>
<p>Those aren’t incompatible choices</p>



<a name="180598834"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180598834" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180598834">(Nov 13 2019 at 07:23)</a>:</h4>
<p>Possible, yes, desirable, that's debatable (I think not personally)</p>



<a name="180598840"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180598840" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180598840">(Nov 13 2019 at 07:23)</a>:</h4>
<p>What’s the downside ?</p>



<a name="180598844"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180598844" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180598844">(Nov 13 2019 at 07:23)</a>:</h4>
<p>It’s just an optimization attribute</p>



<a name="180598888"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180598888" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180598888">(Nov 13 2019 at 07:24)</a>:</h4>
<p>If someone wants to avoid it they can use an attribute</p>



<a name="180598904"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180598904" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180598904">(Nov 13 2019 at 07:24)</a>:</h4>
<p>Having differences between "unknown" and known feels even more inconsistent so to speak</p>



<a name="180598914"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180598914" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180598914">(Nov 13 2019 at 07:24)</a>:</h4>
<p>as for nounwind being the default, I think the hackmd elaborates</p>



<a name="180598922"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180598922" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180598922">(Nov 13 2019 at 07:24)</a>:</h4>
<p>so I won't repeat those arguments</p>



<a name="180598926"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180598926" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180598926">(Nov 13 2019 at 07:24)</a>:</h4>
<p>It’s not a difference between known and unknown</p>



<a name="180598935"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180598935" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180598935">(Nov 13 2019 at 07:25)</a>:</h4>
<p>Known functions can be nounwind as well</p>



<a name="180598939"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180598939" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180598939">(Nov 13 2019 at 07:25)</a>:</h4>
<p>then I don't understand what you are saying</p>



<a name="180598950"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180598950" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180598950">(Nov 13 2019 at 07:25)</a>:</h4>
<p>we have 3 things: imports, exports, pointers</p>



<a name="180598956"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180598956" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180598956">(Nov 13 2019 at 07:25)</a>:</h4>
<p>nounwind is an optimizer attribute</p>



<a name="180598993"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180598993" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180598993">(Nov 13 2019 at 07:25)</a>:</h4>
<p>well unless you allow negative reasoning, in which case you can do type based reasoning on it</p>



<a name="180599039"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180599039" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180599039">(Nov 13 2019 at 07:26)</a>:</h4>
<p>We can apply nounwind to declarations (imports) by default and say that if they unwind the behavior is undefined, and that you can use an attribute to allow that</p>



<a name="180599046"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180599046" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180599046">(Nov 13 2019 at 07:26)</a>:</h4>
<p>The type doesn’t encode that attribute</p>



<a name="180599049"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180599049" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180599049">(Nov 13 2019 at 07:26)</a>:</h4>
<p>So you can’t do any kind of type based reasoning with it</p>



<a name="180599056"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180599056" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180599056">(Nov 13 2019 at 07:27)</a>:</h4>
<p>You cannot express that a function pointer does not unwind, etc</p>



<a name="180599057"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180599057" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180599057">(Nov 13 2019 at 07:27)</a>:</h4>
<p>I know that we can, but it seems strictly less powerful but more costly in terms of spec &amp; compiler internals</p>



<a name="180599061"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180599061" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180599061">(Nov 13 2019 at 07:27)</a>:</h4>
<p>Why more costly ?</p>



<a name="180599068"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180599068" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180599068">(Nov 13 2019 at 07:27)</a>:</h4>
<p>“If it’s a extern C decl, add nounwind I’d attribute not present” we already have this logic</p>



<a name="180599109"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180599109" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180599109">(Nov 13 2019 at 07:28)</a>:</h4>
<p>For the #[unwinds(...)] attribute</p>



<a name="180599115"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180599115" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180599115">(Nov 13 2019 at 07:28)</a>:</h4>
<p>ABI strings are an existing machinery whereas an attribute adds something <em>different</em> in the pipeline</p>



<a name="180599117"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180599117" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180599117">(Nov 13 2019 at 07:28)</a>:</h4>
<p>it's a new sort of category</p>



<a name="180599119"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180599119" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180599119">(Nov 13 2019 at 07:28)</a>:</h4>
<p>and new categories cost more</p>



<a name="180599123"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180599123" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180599123">(Nov 13 2019 at 07:28)</a>:</h4>
<p>We need the attribute any ways</p>



<a name="180599128"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180599128" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180599128">(Nov 13 2019 at 07:29)</a>:</h4>
<p>why that?</p>



<a name="180599129"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180599129" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180599129">(Nov 13 2019 at 07:29)</a>:</h4>
<p>For unknown function, we can’t prove that they don’t unwind</p>



<a name="180599130"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180599130" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180599130">(Nov 13 2019 at 07:29)</a>:</h4>
<p>Even for an extern “Rust”</p>



<a name="180599135"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180599135" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180599135">(Nov 13 2019 at 07:29)</a>:</h4>
<p>Unless we add a more powerful mechanism, like an effect, that we can use instead</p>



<a name="180599182"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180599182" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180599182">(Nov 13 2019 at 07:30)</a>:</h4>
<p>But if we ever do that we can deprecate the FFI Import-only attribute</p>



<a name="180599189"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180599189" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180599189">(Nov 13 2019 at 07:30)</a>:</h4>
<p>I'm not a fan of "can deprecate" reasoning in language design</p>



<a name="180599198"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180599198" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180599198">(Nov 13 2019 at 07:31)</a>:</h4>
<p>Me neither, but adding a new powerful effect by accident feels worse</p>



<a name="180599200"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180599200" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180599200">(Nov 13 2019 at 07:31)</a>:</h4>
<p>(And C++ is a cautionary example wrt. "can deprecate")</p>



<a name="180599214"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180599214" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180599214">(Nov 13 2019 at 07:31)</a>:</h4>
<p>"by accident" suggests we are not aware of what is enabled</p>



<a name="180599254"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180599254" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180599254">(Nov 13 2019 at 07:32)</a>:</h4>
<p>This discussion proves otherwise ^^</p>



<a name="180599255"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180599255" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180599255">(Nov 13 2019 at 07:32)</a>:</h4>
<p>I think that NeverUnwinds is so useful that we should support it without a hack</p>



<a name="180599266"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180599266" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180599266">(Nov 13 2019 at 07:32)</a>:</h4>
<p>You argue that people won’t use it much, but the existence of #[ni_panic] shows otherwise</p>



<a name="180599284"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180599284" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180599284">(Nov 13 2019 at 07:32)</a>:</h4>
<p>People will go long ways to hack themselves into being able to use this feature</p>



<a name="180599299"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180599299" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180599299">(Nov 13 2019 at 07:33)</a>:</h4>
<p>And NeverUnwinds is much better than #[no_panic] so it would at least replace it.</p>



<a name="180599300"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180599300" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180599300">(Nov 13 2019 at 07:33)</a>:</h4>
<p><a href="https://crates.io/crates/no-panic/reverse_dependencies" target="_blank" title="https://crates.io/crates/no-panic/reverse_dependencies">https://crates.io/crates/no-panic/reverse_dependencies</a> -- I'm not convinced by 6 rev deps.</p>
<p>For an unknown function (e.g. via a function pointer), we can <em>assume</em> it doesn't unwind (in the spec, if not in LLVM); we don't need to prove</p>



<a name="180599309"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180599309" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180599309">(Nov 13 2019 at 07:34)</a>:</h4>
<p>But again, there are other reasons for C to be nounwind by default as in the HackMD</p>



<a name="180599357"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180599357" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180599357">(Nov 13 2019 at 07:34)</a>:</h4>
<p>I'm not troubled by having a low-cost extension to the type system being an enabler; you can call it a hack, but it doesn't feel that way to me</p>



<a name="180599362"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180599362" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180599362">(Nov 13 2019 at 07:34)</a>:</h4>
<p>Depends on the reverse deps</p>



<a name="180599369"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180599369" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180599369">(Nov 13 2019 at 07:34)</a>:</h4>
<p>I agree that it's not as general as it could be</p>



<a name="180599374"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180599374" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180599374">(Nov 13 2019 at 07:34)</a>:</h4>
<p>Libm is used by compiler builtins</p>



<a name="180599383"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180599383" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180599383">(Nov 13 2019 at 07:35)</a>:</h4>
<p>Which means is part of the rust runtime</p>



<a name="180599390"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180599390" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180599390">(Nov 13 2019 at 07:35)</a>:</h4>
<p>On WASM at least</p>



<a name="180599402"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180599402" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180599402">(Nov 13 2019 at 07:35)</a>:</h4>
<p>I mean in terms of unique uses of <code>no_panic</code> -- not transitive benefits throughout the ecosystem</p>



<a name="180599452"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180599452" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180599452">(Nov 13 2019 at 07:36)</a>:</h4>
<p>Ah yes, i don’t know how many people directly use the crate</p>



<a name="180599462"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180599462" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180599462">(Nov 13 2019 at 07:36)</a>:</h4>
<p>Just that some low level libraries used by everybody so</p>



<a name="180599465"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180599465" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180599465">(Nov 13 2019 at 07:36)</a>:</h4>
<p>ryu and libm seem big indeed</p>



<a name="180599488"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180599488" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180599488">(Nov 13 2019 at 07:37)</a>:</h4>
<p>I think it might be worth exploring how hard would it be to provide good support for this feature</p>



<a name="180599492"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180599492" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180599492">(Nov 13 2019 at 07:37)</a>:</h4>
<p>And see if that would solve the FFI case</p>



<a name="180599500"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180599500" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180599500">(Nov 13 2019 at 07:37)</a>:</h4>
<p>I don’t think these crates need generics</p>



<a name="180599502"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180599502" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180599502">(Nov 13 2019 at 07:37)</a>:</h4>
<p>you mean like <code>impl nounwind Fn</code>?</p>



<a name="180599503"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180599503" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180599503">(Nov 13 2019 at 07:37)</a>:</h4>
<p>Libm doesn’t at least</p>



<a name="180599550"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180599550" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180599550">(Nov 13 2019 at 07:38)</a>:</h4>
<p>Nounwind fn foo   As a start</p>



<a name="180599555"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180599555" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180599555">(Nov 13 2019 at 07:38)</a>:</h4>
<p>Being generic over it could come later</p>



<a name="180599566"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180599566" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180599566">(Nov 13 2019 at 07:38)</a>:</h4>
<p>probably not a whole lot difficult to implement in the compiler, but actually agreeing to a design and bringing the community on-board would be</p>



<a name="180599589"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180599589" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180599589">(Nov 13 2019 at 07:39)</a>:</h4>
<p>the effects polymorphism and as a modifier on bounds should be designed as a general effects thing, which years of proofing and testing</p>



<a name="180599634"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180599634" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180599634">(Nov 13 2019 at 07:40)</a>:</h4>
<p>I think C++ shows that a lot of code just stamps nounwind all over the place and tries to be generic over it for little benefit. So doing better might be desirable, but can be hard.</p>



<a name="180599655"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180599655" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180599655">(Nov 13 2019 at 07:40)</a>:</h4>
<p>does C++ allow genericity over noexcept?</p>



<a name="180599658"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180599658" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180599658">(Nov 13 2019 at 07:40)</a>:</h4>
<p>Yes</p>



<a name="180599663"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180599663" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180599663">(Nov 13 2019 at 07:41)</a>:</h4>
<p>But I think the const Trait impl solution is better</p>



<a name="180599665"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180599665" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180599665">(Nov 13 2019 at 07:41)</a>:</h4>
<p>can you provide an example for my edification?</p>



<a name="180599668"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180599668" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180599668">(Nov 13 2019 at 07:41)</a>:</h4>
<p>Let me get out of bed</p>



<a name="180599684"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180599684" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180599684">(Nov 13 2019 at 07:42)</a>:</h4>
<blockquote>
<p>But I think the const Trait impl solution is better</p>
</blockquote>
<p>Yea, as with most of Rust and generics (Thanks Haskell &amp; ML!)</p>



<a name="180599832"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180599832" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180599832">(Nov 13 2019 at 07:44)</a>:</h4>
<p>So in C++, <code>noexcept(expr)</code> is a constant expression that returns <code>true</code> if <code>expr</code> cannot unwind, and <code>false</code> otherwise. In C++, <code>noexcept(bool-expr)</code> is also a function qualifier, that sets whether a function can or cannot unwind.</p>
<p>So this code:</p>
<div class="codehilite"><pre><span></span><span class="k">template</span><span class="o">&lt;</span><span class="k">typename</span> <span class="n">T</span><span class="o">&gt;</span>
<span class="n">T</span> <span class="n">generic_add</span><span class="p">(</span><span class="n">T</span> <span class="n">a</span><span class="p">,</span> <span class="n">T</span> <span class="n">b</span><span class="p">)</span> <span class="k">noexcept</span><span class="p">(</span><span class="k">noexcept</span><span class="p">(</span><span class="n">a</span> <span class="o">+</span> <span class="n">b</span><span class="p">))</span> <span class="p">{</span> <span class="k">return</span> <span class="n">a</span> <span class="o">+</span> <span class="n">b</span><span class="p">;</span> <span class="p">}</span>
</pre></div>


<p>is generic over <code>noexcept</code>.</p>



<a name="180599857"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180599857" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180599857">(Nov 13 2019 at 07:45)</a>:</h4>
<p>Now <em>that's</em> a hack :D</p>



<a name="180599862"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180599862" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180599862">(Nov 13 2019 at 07:45)</a>:</h4>
<p>In Rust, instead, we'll write <code>generic_add</code> as follows:</p>
<div class="codehilite"><pre><span></span><span class="k">fn</span> <span class="nf">generic_add</span><span class="o">&lt;</span><span class="n">T</span>: <span class="nc">Add</span><span class="o">&gt;</span><span class="p">(</span><span class="n">a</span>: <span class="nc">T</span><span class="p">,</span><span class="w"> </span><span class="n">b</span>: <span class="nc">T</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">T</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">a</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">b</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
</pre></div>


<p>and whether it is <code>nounwind</code> or not depends on the <code>Add</code> impl, e.g., for <code>Foo</code>:</p>
<div class="codehilite"><pre><span></span><span class="k">impl</span><span class="w"> </span><span class="n">nounwind</span><span class="w"> </span><span class="n">Add</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">Foo</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">add</span><span class="p">(...)</span><span class="w"> </span>-&gt; <span class="p">...</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>



<a name="180599878"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180599878" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180599878">(Nov 13 2019 at 07:46)</a>:</h4>
<p>sure</p>



<a name="180599921"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180599921" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180599921">(Nov 13 2019 at 07:46)</a>:</h4>
<p>So people won't need to stamp <code>nounwind</code> all over the place, and that problem is "solved"</p>



<a name="180599943"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180599943" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180599943">(Nov 13 2019 at 07:46)</a>:</h4>
<p>The main problem with this approach is that its an "all methods of the trait or nothing"</p>



<a name="180599954"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180599954" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180599954">(Nov 13 2019 at 07:47)</a>:</h4>
<p>but that's a problem we already considered acceptable for <code>const fn</code></p>



<a name="180599960"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180599960" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180599960">(Nov 13 2019 at 07:47)</a>:</h4>
<p>I don't think <code>nounwind</code> changes anything here</p>



<a name="180599961"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180599961" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180599961">(Nov 13 2019 at 07:47)</a>:</h4>
<p>can always generalize later</p>



<a name="180599970"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180599970" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180599970">(Nov 13 2019 at 07:47)</a>:</h4>
<p>I agree it doesn't</p>



<a name="180600021"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180600021" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180600021">(Nov 13 2019 at 07:48)</a>:</h4>
<p>So for me I kind of prefer to explore how hard would a minimal solution for this problem be, and if that solution solves the FFI issue or not.</p>



<a name="180600022"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180600022" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180600022">(Nov 13 2019 at 07:48)</a>:</h4>
<p>but <code>arg: impl nounwind Add</code> and <code>arg: impl const Add</code> would be something more</p>



<a name="180600038"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180600038" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180600038">(Nov 13 2019 at 07:48)</a>:</h4>
<p><span class="user-mention" data-user-id="132920">@gnzlbg</span> I understand your point</p>



<a name="180600056"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180600056" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180600056">(Nov 13 2019 at 07:49)</a>:</h4>
<p>I'm not against adding a <code>#[unwind(aborts/allowed)]</code> attribute that's only usable inside <code>extern "C" { imports }</code> as a temporary solution. I would prefer not to do that, but we need to balance shipping with language evolution.</p>



<a name="180600169"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180600169" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180600169">(Nov 13 2019 at 07:50)</a>:</h4>
<p>Personally I think that keeping <code>"C"</code> as nounwind and adding <code>"C unwind"</code> is the most low-cost solution that has the best defaults and disrupts the ecosystem least</p>



<a name="180600205"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180600205" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180600205">(Nov 13 2019 at 07:50)</a>:</h4>
<p>It might also well be that doing that makes also sense even if we had an <code>impl nounwind Trait</code> feature</p>



<a name="180600214"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180600214" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180600214">(Nov 13 2019 at 07:51)</a>:</h4>
<p>I don't know.</p>



<a name="180600280"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180600280" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180600280">(Nov 13 2019 at 07:51)</a>:</h4>
<p>Seems like we've explored the options at least <span aria-label="slight smile" class="emoji emoji-1f642" role="img" title="slight smile">:slight_smile:</span></p>



<a name="180600330"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180600330" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180600330">(Nov 13 2019 at 07:52)</a>:</h4>
<p>Yes</p>



<a name="180600334"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180600334" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180600334">(Nov 13 2019 at 07:52)</a>:</h4>
<p>Might be worth summarizing in a hackmd</p>



<a name="180634396"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180634396" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180634396">(Nov 13 2019 at 15:03)</a>:</h4>
<p>If you think there's a new alternative worth discussing, you could add it to <a href="https://hackmd.io/JIsPlpIPR2yTC051m4Mliw?edit" target="_blank" title="https://hackmd.io/JIsPlpIPR2yTC051m4Mliw?edit">the meaning of C hackmd</a> -- I think an "effect system" variation probably qualifies. I myself am pretty unconvinced right now that we need genericity over this, and I also don't have nearly as many qualms about deprecation and evolution, I suspect. =) I feel like a <code>#[unwind(never)]</code> sort of attribute might well be reasonable. The big question to me though remains how much it matters which we default to, in terms of the interaction with <code>-Cpanic=abort</code>. I don't feel that's resolved yet, it requires some measurement and impl work.</p>



<a name="180634551"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180634551" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180634551">(Nov 13 2019 at 15:04)</a>:</h4>
<p>skimming over the thread, I'm not sure I saw much "reasoning" that didn't appear in there, but it certainly doesn't discuss effect systems</p>



<a name="180634560"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180634560" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180634560">(Nov 13 2019 at 15:04)</a>:</h4>
<p>worth noting that using the ABI <em>also</em> doesn't permit genericity</p>



<a name="180635011"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180635011" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180635011">(Nov 13 2019 at 15:08)</a>:</h4>
<p>to clarify about deprecation: I wouldn't want to <em>plan</em> on deprecating, but I think in this case that (a) generalization is kind of "YAGNI", (b) this is somewhat niche. So, if we do wind up with some kind of effect system we would like to generalize, I would be ok with transitioning this feature over to a new syntax so it can use it.</p>



<a name="180643070"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180643070" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180643070">(Nov 13 2019 at 16:17)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> By "you" do you mean me or <span class="user-mention" data-user-id="132920">@gnzlbg</span> ? I'm personally pretty happy with <code>extern "C unwind"</code> and I agree that this discussion didn't add anything novel</p>



<a name="180643107"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180643107" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180643107">(Nov 13 2019 at 16:17)</a>:</h4>
<p>(Also agree re. "plan on deprecating")</p>



<a name="180643317"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180643317" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180643317">(Nov 13 2019 at 16:19)</a>:</h4>
<p>I meant <span class="user-mention" data-user-id="132920">@gnzlbg</span>, but then I got nerd-swiped and added in some discussion of generics / effects, though I didn't go so far as to add a full blown alternative, because I don't think anybody really wants that</p>



<a name="180643447"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180643447" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180643447">(Nov 13 2019 at 16:20)</a>:</h4>
<p>I definitely want an effect system, but I also think that can wait ;)</p>



<a name="180643835"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180643835" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180643835">(Nov 13 2019 at 16:23)</a>:</h4>
<p>Yes, I meant "I don't think anybody wants that to be done by this group"</p>



<a name="180718819"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180718819" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180718819">(Nov 14 2019 at 10:44)</a>:</h4>
<p>Yes, an effect system is out of scope for this group.</p>



<a name="180718850"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180718850" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180718850">(Nov 14 2019 at 10:45)</a>:</h4>
<p>By adding this feature we are adding a new effect to Rust.</p>



<a name="180718958"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180718958" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180718958">(Nov 14 2019 at 10:46)</a>:</h4>
<p>I'm not suggesting that we should constrain the syntax to be compatible with a future effect system, only that it might maybe be worth it to consider a syntax that does not make it too hard to do so.</p>



<a name="180719110"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180719110" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180719110">(Nov 14 2019 at 10:48)</a>:</h4>
<p>I'm not sure how important this particular effect is, whether it will ever matter to be generic over it, and therefore, I don't know whether more "general purpose" syntax for it (as opposed to "C unwind") would be worth it.</p>



<a name="180719207"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180719207" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180719207">(Nov 14 2019 at 10:49)</a>:</h4>
<p>What I know is that some crates are already making "this function never unwinds" part of their API contract via a quite hacky macro / linker approach</p>



<a name="180719255"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180719255" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180719255">(Nov 14 2019 at 10:50)</a>:</h4>
<p>And some of those APIs do not use the C ABI today</p>



<a name="180719298"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180719298" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180719298">(Nov 14 2019 at 10:51)</a>:</h4>
<p>I would find it a bit weird if with this feature those people would start using the C ABI instead of the Rust ABI to expres "never unwinds"</p>



<a name="180719479"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/noexcept-like%20feature/near/180719479" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/noexcept-like.20feature.html#180719479">(Nov 14 2019 at 10:53)</a>:</h4>
<blockquote>
<p>I'm not suggesting that we should constrain the syntax to be compatible with a future effect system, only that it might maybe be worth it to consider a syntax that does not make it too hard to do so.</p>
</blockquote>
<p>To add to this, we have <code>const</code> which "removes" an effect, <code>async</code> which adds it, attributes like <code>#[target_feature(enable)]</code> which also add effects, etc.</p>
<p>Right now all functions can be made <code>unwinds</code>, so we could add a <code>nounwind</code> syntax to remove that effect. That becomes a bit more complicated if whether a function unwinds or not is part of its "ABI" string, and we have to add both <code>unwinds</code> to add the effect to ABIs that are nounwind by default, and <code>nounwind</code> to remove it (or somehow support <code>!nounwind</code> or <code>!unwinds</code> or similar).</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>